Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equality only supported (not GreaterThan etc) #2

Open
stimpy77 opened this issue Jan 14, 2015 · 2 comments
Open

Equality only supported (not GreaterThan etc) #2

stimpy77 opened this issue Jan 14, 2015 · 2 comments

Comments

@stimpy77
Copy link

How do you support a date range filter, i.e. "all records since Feb 10"? In SQL this would be "WHERE Created >= '2/10......" but the way the GetSelect() is documented you can only pass in a filter of equality column matching (new {ID=3}).

@Yoinbol
Copy link
Collaborator

Yoinbol commented Jan 14, 2015

Hi @stimpy77 thanks for using the tool.
Sadly the current implementation of the "Select" functions is pretty basic and as you pointed out, it only supports equality comparisons.

I have a question: are you using this package with the Dapper.DataRepositories package (https://github.com/Yoinbol/Dapper.DataRepositories)?? Because if you are using both packages together what you can do is extend your repository in order to add a function that will be executing your query.

For instance, let's say you have a "Orders" repository and you want to pull all the orders placed on a specific time interval. In that case, you need to d something like this:

//Repository contract
public interface IOrdersRepository : IDataRepository
{
IEnumerable GetOrdersByInterval(DateTime from, DateTime to);
}

//Repository implementation
public class OrdersRepository : DataRepository, IOrdersRepository
{
public IEnumerable GetOrdersByInterval(DateTime from, DateTime to)
{
return Connection.Query("your sql or your stored procedure name here", new { from, to });
}
}

I know it's a little bit of work because you will need to write your own sql it does not matter if you decide to use raw sql or write a stored procedure, but that's the current scope of both packages. Sorry for the inconvenience.

We can categorise this issue as an enhancement and start to design a way to support what you are asking.

@stimpy77
Copy link
Author

Sorry I missed your follow-up reply. We went to EF shortly after I posted and I don't remember how we were using this tool, but I do appreciate your reply and before our switch to EF I think we did in fact end up using T-SQL as such. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants