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);
and the “where” comes up in red.
Did the Linq2Couchbase API break in 2.3.9?
Hello, is there any body out there?
Yes, definitely-- I pinged @jmorris on it just a couple minutes ago.
By the way, does it still work at the bucket level?
It gives the same sort of error, also says that the bucket.query is obsolete, and I should use cluster.query
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)
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
Rest assured, the query is support by both ICluster and IBucket; the ObsoleteAttribute was removed for v2.3.10 to be released next week.
This is what it looks like on my system.
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.
I think you may be encountering this issue: https://github.com/couchbaselabs/Linq2Couchbase/issues/169
The work-around is to change the Couchbase SDK dependency to 2.3.8. Note that this will be fixed in v2.3.10!
I believe I have the correct and latest versions.
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.
Sorry for the confusion!
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.
Yes, it is a packaging bug. The ticket is here: https://issues.couchbase.com/browse/NCBC-1233