A very brief overview about LINQ to SQL, serialization over WCF and concurrency

image Introduction to LINQ to SQL

LINQ to SQL is part of the new LINQ technology and is available in the .NET framework 3.5. It is natively supported in VS 2008, but you can download the add-ins for VS 2005.

LINQ generates the DAL of your three-tier applications and will let you access your data writing SQL commands directly in your application.

LINQ is lazy, so when you write the query, no action will be performed against the DB.

When you modify the database you will need to *recreate* you “LINQ to SQL classes” file deleting the mappings and dragging them again.


Serialization over WCF

You can not share you “LINQ to SQL classes” between projects. This limitation will be removed in the future.

By the way, you can *serialize* the classes generated by LINQ. Choose Serialization > Unilateral from the LINQ to SQL class designer:


LINQ to SQL supports only unilateral serialization. The problem about serialization concerns the circular references between the tables: A customer links to an order that links to the customer again. With unilateral serializations LINQ will remove circular references starting from the one entity. In this case from the customer to the orders because there will be one customer linked to a lots of orders.

Read this for more infos.


LINQ use optimistic concurrency by default: the query it generates try to match the record using a WHERE field1=oldValueOfField1, field2=….

Because of this, if you use a timestamp it will generate a where clause also for it.

If the UPDATE query fails, a ChangeConflictExceptionis thrown. Using the exception you can decide how to proceed.


I suggest these links about LINQ:


  1. Tom wrote:

    Don’t forget to add linqhelp.com to your list of references and resources!

  2. Sid wrote:

    thx Tom, added!