猿问

ADO.NET Entity framework的查询问题

有下面这么个Linq to entity

传入参数int[] idList,希望让ObjectQuery在数组查询,实现In操作,是这么写的:

 ObjectQuery<Application> query = MainDbGateway.Select<Application>("SELECT Value app from BridgeMain." + MainDbGateway.ApplicationSetName + " as app");


query = (ObjectQuery<Application>)query.Where(a => idList.Any(i => i == a.ApplicationID));
return query.Execute(MergeOption.NoTracking).ToList();

 

编译没问题,可惜运行时就遭遇了异常:

 

“System.NotSupportedException was unhandled by user code
Message="Unable to create a constant value of type 'Closure type'. Only 
primitive types ('such as Int32, String, and Guid') are supported in this 
context."
Source="System.Data.Entity"”

 

请问应该怎么写啊??


智慧大石
浏览 271回答 1
1回答
随时随地看视频慕课网APP
我要回答