We recently updated from 2.3.8 to 2.3.9 and are having trouble getting results with LINQ queries, but N1QL is still working. Previously, we were able to do the following query with Linq:
var query = (from r in bucket.Query<Recording>() where r.Type == "recording" select r);
However, now with the cluster level query if I try the following the compiler does not recognise the syntax:
var query = (from r in cluster.Query<Recording>() where r.Type == "recording" select r);
I am a little confused; the code you show here is the SDK not Linq2Couchbase! Linq2Couchbase uses a BucketContext, which implements IQueryable which allows you to create your Linq expression:
using(var bucket = cluster.OpenBucket("travel-sample"))
{
var context = new BucketContext(bucket);
var query = (from r in context.Query<Recording>() where r.Type == "recording" select r);
foreach(var r in query)
{
Console.WriteLine(r.ToString());
}
}
The IBucket and ICluster implementations have Query methods, but they return an IQueryRequest impl which does not implement IQueryable, therefore does not support Linq.
Perhaps there is a little confusion regarding which API implements IQueryable?
Using NuGet, make sure you have a dependency on Linq2Couchbase which will bring in the Couchbase.NET SDK dependency. The error message indicates you are not referencing the SDK (Couchbase.NetClient) - I think if you make sure the Linq2Couchbase dependency is correct, you should be good.
Change the Couchbase.NetClient dependency to 2.3.8 using the NuGet package manager; there is a bug with 2.3.9 that makes the version incompatible with Linq2Couchbase.
Ok, so there was a break/bug in 2.3.9. Will this be resolved in 2.3.10? Probably worth creating a ticket as well so others will know of the issue. Thanks.