My URI:
$filter=IsActive eq true and IsAutomated eq true and WebSite ne null and WebSite ne '' and LastUpdated le 2018-12-30T23:59:59.99Z
Controller:
private readonly BrokerForgeContext _ctx;[EnableQuery(PageSize = 20)][HttpGet]public IActionResult Get(){ return Ok(_ctx.Locations);}
Startup:
private static IEdmModel GetEdmModel(){ ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet<CashBidPrice>("CashBidPrices"); builder.EntitySet<Location>("Locations"); builder.EntityType<CashBidPrice>().Collection.Function("DeleteToday").Returns<bool>(); return builder.GetEdmModel();}
Entity Model:
public partial class Location{ [Key] public int LocationId { get; set; } public int? Loc_Id { get; set; } public string Name { get; set; } **[[ REMOVED FOR BREVITY ]]** public DateTime? LastUpdated { get; set; }}
I want to get all Locations where the LastUpdate
record is less than today, but having some major issues with filtering on the LastUpdated
record. Everything else works great.
The error:
An unhandled exception occurred while processing the request.SqlException: Conversion failed when converting date and/or time from character string.
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)
TargetInvocationException: Exception has been thrown by the target of an invocation.
System.RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions)