Languages - DevSource
DevSource: Microsoft Developer Resource DevSource Home Sponsored by Microsoft Home Add Ons Architecture Languages Techniques Using VS Forums
Home arrow Languages arrow Microsoft Enters the ORM Space with LINQ
Microsoft Enters the ORM Space with LINQ
By Bob Reselman

Rate This Article: Add This Article To:

LINQ allows developers to work with databases and other types of data stores as objects at a detailed programming level. Here's the least you need to know about this new technology.

Object relational mapping (ORM) products have been one area in which Microsoft has had a dearth of offerings. However, with the introduction of LINQ (.NET Language Integrated Query), this has changed.

LINQ allows developers to work with databases and other types of data stores as objects at a detailed programming level. For example, imagine that you have a database table named Cars, and that Cars has three fields: Make, Model and VIN.

ADVERTISEMENT

Normally, to get the data in Cars to have meaningful representation in your application you would have to:

  • authenticate and bind to the database using a connection string
  • run a SELECT SQL statement to get the data out, then
  • transform it to a DataSet or DataReader object or bind it to some sort of data control to get the data to display.

LINQ reduces this process to applying a single LINQ statement against an object model that you create in Visual Studio using the LINQ designer palette. Then you associate the results of the LINQ statement to a .NET data control. There is no need to write any data access code. LINQ does it all underneath the covers.

Listing 1: An example of LINQ used to bind to a DataGrid

GridView1_MyGrid.DataSource = from car in cars
where car.Make="Ford"
select car;
GridView1.DataBind();

In addition to supporting reading data, LINQ allows you to INSERT, UPDATE and DELETE data without having to write a stitch of data access code. And there is full support for stored procedures.

Figure 1: LINQ allows you to work with database tables as pure objects

In addition to providing you the ability to abstract out SQL database tables into objects, LINQ works with data in other formats, such as XML and RSS feeds. Also, you can apply LINQ to any .NET data type the supports the IEnumerable interface.

LINQ is currently a Community Technology Preview (CTP) product, with a yet to be announced formal release date. You download LINQ here.




Discuss Microsoft Enters the ORM Space with LINQ
 
>>> Be the FIRST to comment on this article!
 

 
 
>>> More Languages Articles          >>> More By Bob Reselman
 



Microsoft's Future: A Chat With Their CTO, Barry Briggs

Play Video >

All Videos >

Julia explores the Robotics Studio!

Read now >

Messages to Bill Gates!

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.