System.Linq.Dynamic.ParseException: 'Operator '>'与操作数类型 'DateTime?' 和 'Int32' 不兼容'
System.Linq.Dynamic.ParseException: 'Operator '>' incompatible with operand types 'DateTime?' and 'Int32''
如何正确解析 sdate?
IQueryable bddata = Junior2KepwareContext.Set(type)
.Where($"C_NUMERICID == {idLinea}")
.Where("C_TIMESTAMP > "+ startDate )
.OrderBy("C_TIMESTAMP");
System.Linq.Dynamic.ParseException: 'Operator '>' incompatible with operand types 'DateTime?' and 'Int32''
您需要使用参数:
IQueryable bddata = Junior2KepwareContext.Set(type)
.Where($"C_NUMERICID == {idLinea}")
// @0 is first parameter in the list, @1 is second etc
.Where("C_TIMESTAMP > @0", startDate) // startDate is of type DateTime, not string
.OrderBy("C_TIMESTAMP");
始终使用参数而不是内联值是一种很好的做法(例如,也将其用于 idLinea
)。
如何正确解析 sdate?
IQueryable bddata = Junior2KepwareContext.Set(type)
.Where($"C_NUMERICID == {idLinea}")
.Where("C_TIMESTAMP > "+ startDate )
.OrderBy("C_TIMESTAMP");
System.Linq.Dynamic.ParseException: 'Operator '>' incompatible with operand types 'DateTime?' and 'Int32''
您需要使用参数:
IQueryable bddata = Junior2KepwareContext.Set(type)
.Where($"C_NUMERICID == {idLinea}")
// @0 is first parameter in the list, @1 is second etc
.Where("C_TIMESTAMP > @0", startDate) // startDate is of type DateTime, not string
.OrderBy("C_TIMESTAMP");
始终使用参数而不是内联值是一种很好的做法(例如,也将其用于 idLinea
)。