SqlFunctions声明它应该只在LINQ to Entities中使用。 DbFunctions也是。但是,当我尝试使用SqlFunction时,它会说,DateDiff
无法翻译!
为什么呢?它们之间有什么区别(除了方法签名)?它们是否与特定版本相关联?
EDIT1
如果您将DbFunctions
替换为SqlFunction
,则生成的查询将不会翻译并抛出异常
case "<>":
return a => a.id_indice == indice.id && indice.tipoDado == (int)enumTipo.Data && DbFunctions.DiffDays(a.valorDateTime, data) == 0;
case ">":
return a => a.id_indice == indice.id && indice.tipoDado == (int)enumTipo.Data && DbFunctions.DiffDays(a.valorDateTime, data) > 0;
case "<":
return a => a.id_indice == indice.id && indice.tipoDado == (int)enumTipo.Data && DbFunctions.DiffDays(a.valorDateTime, data) < 0;
case ">=":
return a => a.id_indice == indice.id && indice.tipoDado == (int)enumTipo.Data && DbFunctions.DiffDays(a.valorDateTime, data) >= 0;
case "<=":
return a => a.id_indice == indice.id && indice.tipoDado == (int)enumTipo.Data && DbFunctions.DiffDays(a.valorDateTime, data) <= 0;