Is there a way to compare a string value to a DateTime object with LinqToEntities?

What i need to do: In my view, add a filter for date, to show only results from an user-chosen day.

How tried to do it: The MVC's architecture demands any information to go through my service layer first, and so I don't really know how to build the query string for my where clause of a LinqToEntities query. The information that comes from the view is collected at the controller (get/post actions), the controller then calls for a service method that builds a where clause and calls on a repository method that lists all DB objects that fit the comparison of my where clause (a string) and a DateTime object in the database. This is the service part where I don't know how to use LinqToEntities and I really don't know how to search for an answer online. I've tried...

Is there a better way to do this, should i move stuff to other layers or change the logic of what i'm doing in some way?

The trick is: I don't know of a way to pass along an instance of DateTime inside this query string that I'm building...

TL;DR: I'm recieving a string value from a single datepicker in my view, and i need to compare it to a DateTime object using LinqToEntities...

Edit: Added questions and explained what i'm trying to do a little better;

Posted Aug 14, 2017, 7:22 PM UTC · edited

13
Loading comments…