Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

ADO.NET vNext Part 3: Querying with LINQ

LINQ provides a straightforward yet expressive SQL-like syntax with which you can query an Entity Data Model and uses anonymous types to return strongly-typed results.


advertisement
he previous article in this series introduced the core concepts of Object Services Layer, including the steps to perform CRUD (Create, Read, Update and Delete) operations against the Entity Data Model (EDM). With that foundation, this installment focuses on using LINQ to query the EDM. Specifically, this article focuses on the expressive query capabilities of LINQ in querying the EDM through the object services layer. By using LINQ on top of the EDM, you can perform operations such as sorting, joining multiple tables, projecting result sets and so on.
 
Figure 1. Using LINQ on top of ADO.NET Object Services Layer: The figure shows the role of the LINQ framework in the overall architecture of ADO.NET vNext.
Figure 1 shows how client applications can work with the object services layer either through LINQ or Entity SQL.


Using LINQ vs. Entity SQL
If you are using the map provider to connect to the database, the only way you can execute queries is through Entity SQL. However when using the object services layer, you can use either Entity SQL or LINQ to work with the object services layer as shown in Figure 1. So when should you use LINQ as opposed to Entity SQL? The answer depends on your requirements. For example, if you need to construct and execute queries dynamically, Entity SQL will fit the bill. Otherwise, LINQ might be a better choice because its strongly typed nature provides you with compile-time checking and Intelliesense. Note that LINQ and Entity SQL are not mutually exclusive and you can seamlessly mix-and-match LINQ and Entity SQL with no restrictions.

What You Need
To follow along with this article series, you need:


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap