我想获得Stored Procedure
查询
var labratorySerialFinalResult = repository.UoW.Orm.Database.SqlQuery<SPLabratorySerialFinalResult>("EXECUTE LabratorySerialFinalResult @OrderNo='" + project.OrderNumber + "'")
并使用如下结果:
var result = projSerials.Where(x =>!labratorySerialFinalResult.Any(v => v.SerialNo == x.SerialNo)
.Union(labratorySerialFinalResult.Where(c => c.FinalResult == "Reject");
但是我遇到以下异常:
Unable to create a constant value of type SPLabratorySerialFinalResult Only primitive types or enumeration types are supported in this context.
答案 0 :(得分:0)
var labratorySerialFinalResult = repository.UoW.Orm.Database.SqlQuery<SPLabratorySerialFinalResult>("EXECUTE LabratorySerialFinalResult @OrderNo='" + project.OrderNumber + "'").AsEnumerable();
var result = projSerials.AsEnumerable().Where(x =>!labratorySerialFinalResult.Any(v => v.SerialNo == x.SerialNo)
.Union(labratorySerialFinalResult.Where(c => c.FinalResult == "Reject");
Referencing Non-Scalar Variables Not Supported
在查询中引用非标量变量(例如实体) 不支持。执行此类查询时,会出现NotSupportedException 抛出异常,并显示一条消息,指出“无法创建一个 EntityType类型的常量值。只有原始类型('如 在此上下文中支持Int32,String和Guid'。“