question is about .NET Core 2. I am not using any ORM, because my application is not a simple CRUD, so I write SQL queries myself (I only use EntityFramework for user identity).
But now I have a problem. It turns out that I should have several nearly same methods in my service that return a dataset. They are pretty the same, but SQL "WHERE" clauses are different. So I thought about having one method with lambda expression so I could write something like:
service.GetRecords<Person>(p => p.FirstName == "Jack" && p.City == "NY");
But I didn't find any way to achieve it without ORM using just plain ADO .NET. Is there some ready tool for that? I don't need it to create full SQL query. I just need it to create WHERE clause, like:
"FirstName = 'Jack' and City = 'NY'"
I tried to write something by myself (using System.Linq.Expressions) but it's really time consuming. So is there a better way or ready to use tool?
The other thing that would suit me (it would even be better) would be if there was a way to combine IDataReader
with IQueryable
.