SqlFunctions states that it should be used only in LINQ to Entities. DbFunctions also. But when I try SqlFunctions it says that, for example, DateDiff
cannot be translated!
Why? What is the difference (besides methods signatures) between them? Are they tied to a specific version?
Edit1
If you replace DbFunctions
for SqlFunction
the resulting query wont translate and throw a exception
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;