Ben Hall (UK)

Hello,

With the LinqDataSource, when I select all of the columns (*) I can edit and delete records via a GridView however, if I select only certain columns the options are not available - even if I select all the columns.

Secondly, if I go direct to the object and not via the DataContext and select * for all columns, I don't get Update and Delete functionality.

Would be great if these two scenarios where supported. Hope this makes sense.

Ben




Re: LINQ Project General LinqDataSource - Update/Delete options not available

jwooley

I believe you may be running into the issue of the immutability of anonymous types with LINQ to SQL. See Paul Vick's posting at http://www.panopticoncentral.net/archive/2007/05/11/20566.aspx for more information.

Jim Wooley






Re: LINQ Project General LinqDataSource - Update/Delete options not available

Dinesh Kulkarni - MSFT

There is a bit more to mutability.

As Jim correctly points out, anonymous types in projection are immutable.

In LINQ to SQL, the ability to update/delete/insert is tied to the "entity"ness of a class. If the class has object id defined using IsPrimaryKey=true on one or more members, it is an entity and changes to it are tracked. In LINQ to SQL, non-entity projections are not change tracked (i.e. not updatable/insertable/deletable). This is true for both named and anonymous types. A simple way to think about it is that LINQ to SQL performs change operations on objects with object identity. Object identity is defined in mapping and no identity means no change operations.

HTH

Dinesh

http://blogs.msdn.com/Dinesh.Kulkarni/