MicroOrm.Pocos.SqlGenerator
MicroOrm.Pocos.SqlGenerator copied to clipboard
Where between
Hi I would like to now how can I filter a GetSelect between 2 dates
Hi. I know this is a very basic feature but sadly the library doesn't support it out of the box. If you are using this library with the Dapper.DataRepositories library, what you can do is to extend the repository where you want to apply a filter like this and write your own sql statement or even better use a stored procedure.
Something like this: (lets say you are working with an "Orders" repository):
Define a new function on your repository contract, like this:
public IOrdersRepository: IDataRepository<Order>
{
IEnumerable GetByDate(DateTime start, DateTime end);
}
And then implement your function on the repository, like this:
public OrdersRepository: DataRepository<Order>, IOrdersRepository
{
public IEnumerable GetByDate(DateTime start, DateTime end)
{
return Connection.Query<Order>("... your sql or your store procedure ...", new { start, end });
}
}