3 ms·
What is the code to get the number of cars with expired insurence when using Dapper?
by TekMol 8y ago
What is the code to get the number of cars with expired insurence when using Dapper?
- fuzzy2 8y agoSomething along the lines of db.Query<Car>("SELECT * FROM Cars WHERE InsuranceEndDate < @Date", new { Date = DateTime.Now }); /edit: Sorry, missed the "number of". Well, you get the idea. It'd use 'QuerySingle' instead.
- TekMol 8y agoThat does not look very ORMish to me. It might return objects. But isn't one point of an ORM that you tell the ORM which data you want and not what SQL query to send to the DB?
- tfigment 8y agoAlso Dapper fan. I like mapping into objects without code generation and complicated queries are easier to write compared to LINQ if familiar with actual SQL. Only thing I really don't like is bulk inserts as it will do one statement per object. You can still use both Dapper and LINQ at same time but it might confuse others.