From 237d712552bfc549a00b8f3cdab8a7fcad98f4b0 Mon Sep 17 00:00:00 2001 From: Reuzel Date: Sat, 19 Apr 2014 01:08:23 +0200 Subject: [PATCH] Release preparation --- .../CqlSharp.Linq.PerformanceTest.csproj | 4 +- CqlSharp.Linq.PerformanceTest/packages.config | 2 +- CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj | 4 +- CqlSharp.Linq.Test/SerializationTest.cs | 4 +- CqlSharp.Linq.Test/packages.config | 2 +- CqlSharp.Linq/CqlSharp.Linq.csproj | 4 +- CqlSharp.Linq/CqlSharp.Linq.nuspec | 21 +++-- CqlSharp.Linq/Properties/AssemblyInfo.cs | 9 +- CqlSharp.Linq/packages.config | 2 +- README.md | 92 +++++++++++++++++-- 10 files changed, 114 insertions(+), 30 deletions(-) diff --git a/CqlSharp.Linq.PerformanceTest/CqlSharp.Linq.PerformanceTest.csproj b/CqlSharp.Linq.PerformanceTest/CqlSharp.Linq.PerformanceTest.csproj index adb8cbc..b1b4f7a 100644 --- a/CqlSharp.Linq.PerformanceTest/CqlSharp.Linq.PerformanceTest.csproj +++ b/CqlSharp.Linq.PerformanceTest/CqlSharp.Linq.PerformanceTest.csproj @@ -32,9 +32,9 @@ 4 - + False - ..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll + ..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll diff --git a/CqlSharp.Linq.PerformanceTest/packages.config b/CqlSharp.Linq.PerformanceTest/packages.config index cda0e9d..7bc91c3 100644 --- a/CqlSharp.Linq.PerformanceTest/packages.config +++ b/CqlSharp.Linq.PerformanceTest/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj b/CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj index 80d4a3b..808a052 100644 --- a/CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj +++ b/CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj @@ -35,9 +35,9 @@ 4 - + False - ..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll + ..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll diff --git a/CqlSharp.Linq.Test/SerializationTest.cs b/CqlSharp.Linq.Test/SerializationTest.cs index fbd7858..a040fa6 100644 --- a/CqlSharp.Linq.Test/SerializationTest.cs +++ b/CqlSharp.Linq.Test/SerializationTest.cs @@ -219,7 +219,7 @@ public void SerializeObjectOutDefaultsTest() [TestMethod] public void SerializeObjectInOutDefaultsTest() { - var values = new Types() { aInt = 3, aTimeUUID = TimeGuid.Default }; + var values = new Types { aInt = 3, aTimeUUID = TimeGuid.Default }; using (var context = new SerializationContext()) { @@ -387,7 +387,7 @@ public void SerializeNullableObjectInOutDefaultsTest() // ReSharper disable InconsistentNaming - public class SerializationContext : CqlContext + private class SerializationContext : CqlContext { public SerializationContext() : base(ConnectionString) diff --git a/CqlSharp.Linq.Test/packages.config b/CqlSharp.Linq.Test/packages.config index cda0e9d..7bc91c3 100644 --- a/CqlSharp.Linq.Test/packages.config +++ b/CqlSharp.Linq.Test/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/CqlSharp.Linq/CqlSharp.Linq.csproj b/CqlSharp.Linq/CqlSharp.Linq.csproj index d3d147c..64e9eb9 100644 --- a/CqlSharp.Linq/CqlSharp.Linq.csproj +++ b/CqlSharp.Linq/CqlSharp.Linq.csproj @@ -30,9 +30,9 @@ 4 - + False - ..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll + ..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll diff --git a/CqlSharp.Linq/CqlSharp.Linq.nuspec b/CqlSharp.Linq/CqlSharp.Linq.nuspec index 9ee3172..4937f02 100644 --- a/CqlSharp.Linq/CqlSharp.Linq.nuspec +++ b/CqlSharp.Linq/CqlSharp.Linq.nuspec @@ -3,26 +3,35 @@ $id$ $version$ - CQLSharp.Linq - Linq provider for querying Cassandra using CqlSharp + CQLSharp.Linq - Linq-2-Cql provider for interacting with a Apache Cassandra database Joost Reuzel Joost Reuzel http://www.apache.org/licenses/LICENSE-2.0 - https://github.com/reuzel/CqlSharp/wiki + https://github.com/reuzel/CqlSharp.Linq https://raw.github.com/reuzel/CqlSharp/master/logo.png false - CqlSharp.Linq contains a Linq to Cql provider on top of CqlSharp allowing Linq queries to be executed against an Apache Cassandra database. - CqlSharp.Linq contains a Linq to Cql provider on top of CqlSharp allowing Linq queries to be executed against an Apache Cassandra database. + CqlSharp.Linq contains a Linq-to-Cql provider for use with the Apache Cassandra database. + + Main features are: + * Translation of Linq queries to CQL select statements. + * All CQL functions are supported, as well as tokens and the allow filtering clause. + * Consistency and Paging query behaviour can be set per query via IQueryable extensions + * Linq projections (IQueryable.Select statements) can become arbitrarily complex + * Generated mapping of query results to objects is extremely fast, through compiled expressions + * Linq queries can be (pre-)compiled for increased performance + * Snapshot-based entity change tracking is supported, allowing for easy insert, change and updates of entities + * Change tracking can be switched off globally or per query + * CqlSharp.Linq provides an EntityFramework like interface CqlSharp is a high performance, asynchronous Cassandra CQL binary protocol client implementing the ADO.NET data provider interfaces. See https://github.com/reuzel/CqlSharp/wiki/Features for an extensive feature list. - Version 0.31.0 - Initial version + Version 0.36.0 - Initial Release * number chosen to match corresponding CqlSharp package version - See https://github.com/reuzel/CqlSharp/blob/master/ChangeLog.md for the full changelog. Copyright 2014 Joost Reuzel Cassandra CQL Linq client database provider nosql net45 CqlSharp diff --git a/CqlSharp.Linq/Properties/AssemblyInfo.cs b/CqlSharp.Linq/Properties/AssemblyInfo.cs index 1018ab4..9d348d0 100644 --- a/CqlSharp.Linq/Properties/AssemblyInfo.cs +++ b/CqlSharp.Linq/Properties/AssemblyInfo.cs @@ -24,9 +24,9 @@ [assembly: AssemblyTitle("CqlSharp.Linq")] [assembly: AssemblyDescription("CQLSharp.Linq - Linq provider for querying Cassandra using CqlSharp")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Joost Reuzel")] [assembly: AssemblyProduct("CqlSharp.Linq")] -[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyCopyright("Copyright Joost Reuzel © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -51,9 +51,8 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.34.0.0")] -[assembly: AssemblyFileVersion("0.34.0.0")] -[assembly: AssemblyInformationalVersion("0.34.0.0-alpha")] +[assembly: AssemblyVersion("0.36.0.0")] +[assembly: AssemblyFileVersion("0.36.0.0")] #if DEBUG diff --git a/CqlSharp.Linq/packages.config b/CqlSharp.Linq/packages.config index cda0e9d..7bc91c3 100644 --- a/CqlSharp.Linq/packages.config +++ b/CqlSharp.Linq/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/README.md b/README.md index 933150b..f88418a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,17 @@ -CqlSharp.Linq -============= +#CqlSharp.Linq -CQLSharp.Linq - Linq provider for querying Cassandra using CqlSharp +CqlSharp.Linq contains a Linq-to-Cql provider for use with the Apache Cassandra database. +Main features are: +* Translation of Linq queries to CQL select statements. +* All CQL functions are supported, as well as tokens and the allow filtering clause. +* Consistency and Paging query behaviour can be set per query via IQueryable extensions +* Linq projections (IQueryable.Select statements) can become arbitrarily complex +* Generated mapping of query results to objects is extremely fast, through compiled expressions +* Linq queries can be (pre-)compiled for increased performance +* Snapshot-based entity change tracking is supported, allowing for easy insert, change and updates of entities +* Change tracking can be switched off globally or per query +* CqlSharp.Linq provides an EntityFramework like interface ## Context and Table CqlContext and CqlTable are the classes that form the core of the provider. CqlContext is the IQueryProvider, while CqlTable is the IQueryable. @@ -63,6 +72,9 @@ The following operations are supported: * Single * SingleOrDefault * ToList +* ToArray +* ToDictionary +* ToLookup * OrderBy * OrderByDescending * ThenBy @@ -86,19 +98,83 @@ All the CQL functions (including TTL and WriteTime) are supported through the Cq Last, the query can be influenced through the following IQueryable extensions: * AllowFiltering(); adds the Allow Filtering option to the query +* AsNoTracking(); switches off change tracking for the returned entities +* WithConsistency(); sets the required consistency level for the given query +* WithPageSize(); enable result set paging for queries that return large numbers of results + +##Compiled Queries +Queries may be compiled for increased performance: + +```c# + Func compiledQuery = + CompiledQuery.Compile + ( + (context, id, append) => context.Comments + .Where(comment => comment.CommentId == id) + .Select(comment => comment.Value + append).First() + ); + + ... + + string GetWithGoodComment(Guid commentId) + { + using (var context = new MyContext(ConnectionString)) + { + return compiledQuery(context, commentId, "!!GOOD COMMENT!!"); + } + } +``` + +##Change Tracking +CqlSharp.Linq implements snapshot based change tracking. Simply query for the entities, make some changes and +save the changes by invoking SaveChanges on the responsible context. + +```c# + + using(var context = new MyBlogContext()) + { + var comment = context.Comments + .Where(c => c.Blog == blogid).First(); + + comment.Text = "a new comment text"; + + context.SaveChanges(); + } +``` + +Entities can be inserted, deleted, attached or detached through the different CqlTable methods. + +When a query does not contain a projection (IQueryable.Select() method invocation), the results will be automatically tracked. +This includes any entities queried through a compiled query. This tracking behaviour can be changed, by either setting the +context.TrackChanges property to disable change tracking for the whole context, or by adding the AsNoTracking query method to +an Linq query. + +Insight in the detected changes can be obtained through the context.ChangeTracker. There all tracked entities can be queried +and checked for their current state. + +Any changes will be send as part of a transaction. Transactions can be influenced through the context.Database +CurrentTransaction property and the BeginTransaction and UseTransaction methods. Moreover, automatic acceptance of entity +changes can be influenced through the acceptChangesDuringSave parameter of the SaveChanges method. ##Design Most of the ideas on how this provider is created stems from a blog series from Matt Warren: [LINQ: Building an IQueryable provider series](http://blogs.msdn.com/b/mattwar/archive/2008/11/18/linq-links.aspx) -The general concept behind this Linq provider implementation is that a regular Linq expression tree is transformed into an expression tree that contains Cql expressions such as select, relation term, etc. Using cql specific expression types the original query can be adapted to contain references (expressions) to column values, allowing reasoning about the meaning of the different operations. +The general concept behind this Linq provider implementation is that a regular Linq expression tree is transformed into +an expression tree that contains Cql expressions such as select, relation term, etc. Using cql specific expression types +the original query can be adapted to contain references (expressions) to column values, allowing reasoning about the meaning +of the different operations. + +The final expression tree is translated into a query plan consisting of +* a cql query +* a projector mapping results from a datareader into the required result form (object or value type) +* an aggregator, translating the projected results into the required form (e.g. by taking the first item from the set) -The final expression tree is translated into a Cql query as well as delegate that transforms the query -results into the required object structure. +The API as well as the change tracking functionality is largely inspired by Microsoft's EntityFramework. ##TODO -* A lot of testing +* ~~A lot of testing~~ * ~~Cql Function support (Token, TTL, ...)~~ * Database creation logic -* Create/Update/Delete functionality +* ~~Create/Update/Delete functionality~~