4 ms·
weird. .NET ORMs don't do this (at least Entity Framework Core) `db.Users.Select(x => new { x.Name, x.Age }).ToListAsync()` will perform something like `SELE
by tester34 6y ago
weird.
.NET ORMs don't do this (at least Entity Framework Core)
`db.Users.Select(x => new { x.Name, x.Age }).ToListAsync()`
will perform something like `SELECT Name, Age FROM db.Users`
but ofc if you tell it to load everything `db.Users.ToListAsync()`
then it will perform
`SELECT Name, Age, Salary, ... FROM db.Users`
but not *
- patates 6y agoThat made me realize how much I missed .NET and my favorite tool LINQPad. Add Dapper next to your advanced ORM and you're basically unstoppable.
- tester34 6y agoI do agree that combination of powerful ORM + light wrapper over raw SQL like Dapper makes stuff way easier (faster, less boilerplate-ish) while maintaining decent performance. People tend to say that: EF Core for saving data in db (because it detects changes and shortens code really hard) and Dapper for reads - writting manually good queries
- fabian2k 6y agoI was about to post the same thing. This works perfectly fine for EF Core, as long as you're aware that the mapping has to be directly in the Select like this so that it can be translated to SQL.
- tester34 6y agoExactly, you just have to check how's your query evaluation process doing if you want to do fancy stuff that SQL may struggle with / don't understand