我正在尝试使用c#驱动程序进行查询。文件结构是:
{
"_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
}
我试图运行的查询是:
collection.AsQueryble().Where(
er =>
er.CareerCultureExternalResources.Any(
ccer => ccer.CareerId == request.CareerId && ccer.CultureId == request.CultureId));
传递值careerId = 637
和cultureId = 1
,我收到错误:"Unsupported where clause: ((Int32)ccer.CareerId == 637)"
然而,在MongoDb教程页面上,它说明了这种查询: http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/
我使用的是驱动程序的1.8.3版本
答案 0 :(得分:1)
目前,在使用Linq时,使用where
和类似已完成的条件子句仅限于.NET数据类型的子集。不是使用short
,而是使用Int32
/(int
)。