开发者

ASP.NET -Advantages of LINQ

Recently I am using LINQ. But when facing an interview I am unable to explain:

  1. What is LINQ?

  2. Moreover, is DataSet deprecated due to the introduction of LINQ?

From an interview point of view, how should I an开发者_Go百科swer those questions?


LINQ is a set of extensions to the .NET framework that enables language-integrated queries. This basically means that we can use the same type of syntax to query any set of data - whether it be a SQL database, Active Directory, or XML file - we can use the same syntax to execute queries.

The mechanism that LINQ uses to communicate with the different datasources is through providers - you can write your own provider if you wish, but the default providers are LINQ-to-Objects, LINQ-to-SQL and LINQ-to-XML. So again - LINQ allows you to use the same syntax for retrieving data from a SQL database, XML file or in-memory objects.

LINQ does not replace DataSets - in fact, you can use LINQ in conjunction with datasets. The only reason why there is a debate of DataSets vs LINQ is due to LINQ-to-SQL being an ORM. This means that we now have a choice in terms of built-in technologies for communicating with the database - previously datasets would be the default built-in option, now you can also opt for LINQ-to-SQL.


Nice introduction to LINQ Just pick few most important sequences from there for your interview question. As for the second question DataSet's are not deprecated, LINQ is just adding a different way you can work with your data.


In addition to what @RaYell said you should have asked your interviewer if they were talking about LINQ or LINQ to SQL when asking if the DataSet was deprecated.


Entity Framework replaces LINQ to SQL, using an OOD approach, shielding it from the database with a mapping layer. This layer uses xml and csql to enable it to pass the data to a variety of databases, without the overhead of sql. The objects dont expose any tables, and neither would you expect it, as the objective is to abstract to enable mapping. This is clearly at odds with the dataset approach. I guess if you considered "Entity Framework to Dataset", or "Entity Framework to XML" in the same vein as LINQ, and to enable loading of these objects shielded by mapping, then you can see the value of each of these technologies. Such transformation atm seem to be via LINQ to XML, or LINQ to DATASET, and then pushing into Entity Framework. I would add that the DataSet allows for accessing tables, rows, columns dynamically and I am not sure the Entity FrameWork has such capability, it must know the data framework, hence they are complementary technologies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜