I have a collection I am trying to query using the c# driver. the document structure is:
{
"_id" : 3121 ,
"Active" : true ,
"CategoryId" : 1 ,
"Crci" : "IH" ,
"CultureId" : null ,
"DateUpdated" : {
"$date" : 1381916923120
} ,
"Description" : "National Careers Service: Actuary" ,
"Keywords" : "" ,
"MaxLevel" : null ,
"MinLevel" : null ,
"PhoneNumber" : " " ,
"Priority" : 1 ,
"Title" : "National Careers Service: Actuary" ,
"WebUrl" : "https://nationalcareersservice.direct.gov.uk/advice/planning/jobprofiles/Pages/actuary.aspx" ,
"CareerCultureExternalResources" : [
{
"CareerId" : 5 ,
"CultureId" : 1 ,
"DisplayOrder" : 1 ,
"ExternalResourceId" : 3121 ,
"Vgs" : null
}
] ,
"SubjectExternalResources" : [ ] ,
"LifestyleCategories" : null
}
the query I am trying to run is:
collection.AsQueryble().Where(
er =>
er.CareerCultureExternalResources.Any(
ccer => ccer.CareerId == request.CareerId && ccer.CultureId == request.CultureId));
passing the values careerId = 637
and cultureId = 1
, I get the error: "Unsupported where clause: ((Int32)ccer.CareerId == 637)"
However on the MongoDb tutorials page it says this kind of query is covered: http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/
I am using version 1.8.3 of the driver
Currently, using where
and a conditional clause like you've done, when using Linq, is limited to a subset of .NET data types. Instead of using a short
, use a Int32
/(int
) instead.