6 ms·
The language issue you raise is in part solved by C# and Entity framework. Because of the lazy way it works you can define a single select over a table, then a
by boyter 12y ago
The language issue you raise is in part solved by C# and Entity framework.
Because of the lazy way it works you can define a single select over a table, then apply extension methods, joins etc.. over the return of this select and you end up with a highly reusable clean easily tested data layer. Done right you get code like the following,
var url = _urlRepo.GetUrl().OrderByCreateDate().ByCreatedUser("boyter");
var url2 = _urlRepo.GetUrl().OrderByCreatedUser().ByDomain("geocities");
Or with joins,
var users = _userRepo.GetUser();
var locations = _locationRepo.GetLocation();
var result = from user in users
join location in locations on user.locationid equals location.id && location.name = "Parramatta"
select user;
I wrote about this a bit here http://www.boyter.org/2013/07/clean-repository-data-access-c/ http://www.boyter.org/2013/07/clean-repository-data-access-c... and it is to date the cleanest way I have come across in any language to deal with SQL. Compile time checked, reusable and testable.
Its the best ORM I have found so far across any language. I would dearly love to have it ported to other languages and frameworks.
- NDizzle 12y agoIt's funny you mention entity framework. That's what blows up tempdb on one of my many environments with some of the stupidest queries I've ever seen hit the server. Maybe your experience with entity is better than mine, but I personally think it and most other ORMs are complete garbage.
- dasboth 12y agoI agree with this (sort of). I find Entity Framework very usable and it does help you write descriptive and maintainable code, but the SQL queries it ends up writing makes it a performance nightmare. YMMV of course but for applications where performance is important I haven't found EF to perform adequately. As ORMs go all I really want is an abstraction layer and the mapping from query to POCO classes without the performance hit. Currently using Dapper.
- sequence7 12y agoAlthough I understand your frustration if SQL queries were blowing up tempdb would you blame SQL or would you blame the developers writing those stupid queries? ORMs are not a magic bullet and developers can do stupid things with any tool.
- Pxtl 12y agoI use entity framework. Like any ORM it has some abstraction leaks and a few warts, but all in all it only cemented my opinion above that SQL is holding RDBMS systems back.