Cannot assign value to member XXX. It does not define a setter.

One of the great things about LINQ to SQL is that you can add additional properties to the auto-generated classes via partial classes.  However, occasionally people will run into this exception: System.InvalidOperationException: Cannot assign value to member 'XXX'. It does not define a setter.  Why does this sometimes happen whereas other times the "extra" properties added via the partial class work perfectly?  To answer this, let's take an example. Suppose we have a contacts class (I've left...


CMAP Code Camp Spring 2008 - Code Samples

The code samples from my recent presentation at the Maryland CMAP code camp can be downloaded here:  LINQ to SQL [http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=michelotti&DownloadId=1791%5D]...



CMAP Presentation - LINQ to SQL

This Thursday I'll be giving on presentation on LINQ to SQL at the CMAP Developer group: http://cmap-online.org/Meetings/Details/2008-02-21.aspx...


Handle Insert/Update/Delete of child entity in tiered application

Recently I've done a series of posts all related to using Linq in a tiered application: The various posts (which have been influenced by this MSDN article [http://msdn2.microsoft.com/en-us/library/bb546187.aspx]) have focused on a DataContext that looks like the diagram below.  The Contact class generated has a child collection property of Addresses which is of typeEntitySet<Address>.  This distinction is important because the example deals with a complex object that has a collection of child o...