Can someone clarify the key difference between Entity Framework and typed datasets?

I compare EF and typed datasets for their usefulness. I did not understand why you should use EF for typed datasets if EF is attached only to SQL Server. But is it true that Linq expressions in EF have been evaluated recently in the sense that if you did something like:

db.Customers.where(c => c.Name == "John Smith") 

EF will create a query such as:

 select * from Customers where Name = 'John smith' 

But with typed datasets you can write:

 bll.GetCustomers().where(c => c.Name == "John Smith") 

This is very similar, but the difference is that it starts the first time:

 select * from Customers 

And then, using the standard collection library, find the lines containing the name: "John Smith." In theory, the value of EF will be more effective.

Is it correct?

+6
c # entity-framework strongly-typed-dataset
source share
3 answers

Yes. With the Entity Framework, it uses IQueryable<T> to create your queries. Performing:

 var results = db.Customers.Where(c => c.Name == "John Smith"); 

Inside the results will be an IQueryable<Customer> (or your type). This allows the provider (EF) to optimize how this is done internally. In the case of SQL Server, the actual query sent to the server will already have a SQL WHERE clause, which in turn means that you will only return one record (if the "Name" is unique) back from the database of each record.

Using typed datasets, you return each record, and then search for the results for the corresponding name. This is potentially much less effective.

+4
source share

It is right. Entity Framework is an object-relational file cabinet (ORM). It provides a way to map your objects to relational data for queries. IQueryable<T> used with EF and can mainly optimize the SQL that is sent to and from the server.

+2
source share

No, that is not right. Using typed data sets, you should add a parameter request to the table, for example, "SELECT *" from clients, where name = @name "You must specify the name parameter from your code at run time. This way, you only pull the necessary data into the set Migrating the entire table at first according to Reed’s answer would be extremely inefficient at best and not realistic with a database of any size, which seems to be a common misunderstanding of ADO.Net, immortalized even in some books - especially books about the Entity Framework!

+1
source share

All Articles