Reputation: 4599
Depend on my research and working on EF(and LinQ) for 7 months, It seems that EF (Or LinQ) is a good solution for replacing it with traditional solution(I mean using SqlCommand , SqlConnetion, DataReader and other ADO.Net Components)
Here I have 3 questions :
Regardless of EF and it`s performance usage, Is there anything that I should be worry about it for replacing traditional solution by EF completely?
Look at these 2 codes :
//#1
var UsersEnum = MyDataContext.Users;
return UserEnum.Where(obj => obj.age > 20);
//#2
return MyDataContext.Users.Where(obj.age > 20);
What is the different between these tow codes?!!
The first on , first fetches all records and stores them in variable and then filters them by age and then returns the remaining records
But what about the Second one?does It fetch all records and then filter them? or it fetches just the filtered records (Not all them)?!
3 . What is the different between those tow codes in performance usage? Is there any difference? Or generally it seems EF gets more performance against ADO.Net Components.Is it right?
Sorry about my bad syntax, I am new in English and thanks for your attention. Any Idea and advice can be useful .
Upvotes: 1
Views: 216
Reputation: 32437
Regardless of EF and it`s performance usage, Is there anything that I should be worry about it for replacing traditional solution by EF completely?
EF is an abstraction over ADO.NET. Abstractions are leaky. You will loose some feature of the ADO.NET API but if all your requirements fall nicely will EF's capacity then you are OK. Some example that you will miss with EF are Batch inserts and Batch queries. EF is not a good solution for batch related operations interms of performance. It is good at working with small set of objects.
What is the different between these two codes?!
There is no difference between the two code samples in terms of functionality. Both of them will not issue database requests. This is a feature of LINQ called Differed Execution
What is the different between those tow codes in performance usage? Is there any difference? Or generally it seems EF gets more performance against ADO.Net Components. Is it right?
If 20ms, 30m delay is significant in your application, Then you are better off with ADO.NET. But EF has many other advantages over ADO.NET
Upvotes: 2