Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Release preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
reuzel committed Apr 18, 2014
1 parent b0ba2a8 commit 237d712
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CqlSharp, Version=0.35.1.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="CqlSharp, Version=0.36.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll</HintPath>
<HintPath>..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion CqlSharp.Linq.PerformanceTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CqlSharp" version="0.35.1.0" targetFramework="net45" />
<package id="CqlSharp" version="0.36.0.0" targetFramework="net45" />
</packages>
4 changes: 2 additions & 2 deletions CqlSharp.Linq.Test/CqlSharp.Linq.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CqlSharp, Version=0.35.1.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="CqlSharp, Version=0.36.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll</HintPath>
<HintPath>..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
4 changes: 2 additions & 2 deletions CqlSharp.Linq.Test/SerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -387,7 +387,7 @@ public void SerializeNullableObjectInOutDefaultsTest()

// ReSharper disable InconsistentNaming

public class SerializationContext : CqlContext
private class SerializationContext : CqlContext
{
public SerializationContext()
: base(ConnectionString)
Expand Down
2 changes: 1 addition & 1 deletion CqlSharp.Linq.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CqlSharp" version="0.35.1.0" targetFramework="net45" />
<package id="CqlSharp" version="0.36.0.0" targetFramework="net45" />
</packages>
4 changes: 2 additions & 2 deletions CqlSharp.Linq/CqlSharp.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CqlSharp, Version=0.35.1.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="CqlSharp, Version=0.36.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\CqlSharp.0.35.1.0\lib\net45\CqlSharp.dll</HintPath>
<HintPath>..\packages\CqlSharp.0.36.0.0\lib\net45\CqlSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
21 changes: 15 additions & 6 deletions CqlSharp.Linq/CqlSharp.Linq.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>CQLSharp.Linq - Linq provider for querying Cassandra using CqlSharp</title>
<title>CQLSharp.Linq - Linq-2-Cql provider for interacting with a Apache Cassandra database</title>
<authors>Joost Reuzel</authors>
<owners>Joost Reuzel</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://github.com/reuzel/CqlSharp/wiki</projectUrl>
<projectUrl>https://github.com/reuzel/CqlSharp.Linq</projectUrl>
<iconUrl>https://raw.github.com/reuzel/CqlSharp/master/logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>
CqlSharp.Linq contains a Linq to Cql provider on top of CqlSharp allowing Linq queries to be executed against an Apache Cassandra database.
</summary>
<description>
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.
</description>
<releaseNotes>
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.
</releaseNotes>
<copyright>Copyright 2014 Joost Reuzel</copyright>
<tags>Cassandra CQL Linq client database provider nosql net45 CqlSharp</tags>
Expand Down
9 changes: 4 additions & 5 deletions CqlSharp.Linq/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("")]

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CqlSharp.Linq/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CqlSharp" version="0.35.1.0" targetFramework="net45" />
<package id="CqlSharp" version="0.36.0.0" targetFramework="net45" />
</packages>
92 changes: 84 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -63,6 +72,9 @@ The following operations are supported:
* Single
* SingleOrDefault
* ToList
* ToArray
* ToDictionary
* ToLookup
* OrderBy
* OrderByDescending
* ThenBy
Expand All @@ -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<MyContext, Guid, string, string> compiledQuery =
CompiledQuery.Compile<MyContext, Guid, string, string>
(
(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~~

0 comments on commit 237d712

Please sign in to comment.