Is LINQ to Dataset subset of LINQ to EF or these two are independent?

醉酒当歌 提交于 2019-12-05 18:16:40

Linq works with the concept of queryProviders. The query provider is responsible for translating the lamba expressions into queries on the underlying data store. as Obalix said before me Linq to Entities query provider translates the linq with lambdas into real sql which is executed using underlying ado.net objects. Take a look at canonical functions here, which are translated into sql (and take notice which are not). On the other hand linq to dataset works against DAtaSet infrastructure. As you may remember Data Set has some queries associated with it. (getters, updates, deletes, inserts) with the usage of the DataAdapters objects. Linq queries are mapped onto objects that already exist in the dataset = tables, columns etc. The SQL queries are not built, because the provider does not operate at such a low level - the data set is the data abstraction it uses.

You might take a look at linq to SQL if Database agnosticism is not You concern, and there is even some provider linq to Oracle if I heard correctly.

They are independent.

  • Linq to Dataset works against a DataSet that was previously created using ADO.NET. The dataset is loaded prior to using linq, so the SQL queryies are not build dynamicly.

  • Linq to EntityFramework works against entity framework context. Here the SQL queries are constructed dynamically, based on the Linq query you provided.

They are independent and don't even work together very well.

LINQ-to-Datatsets is a set of extension methods that allows LINQ queries against data already loaded into DataTables, based on IEnumerable. It is close to querying List<> and other collections.

LINQ-to-Entities uses query providers and IQueryable to translate LINQ queries into SQL queries. It also provides for modeling of the database tables as objects.

If you use EF you are able to write (much more) Object Oriented, using DataSets remains Database Oriented.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!