ADO.NET Data Service gives you the ability to do:

  • Read/Write with ADO.NET Entity Framework
  • Read only with LINQ to SQL

The reason it is read only for LINQ to SQL is that Data Services needs to object model that it is exposing to implement IUpdatable. LINQ to SQL does not.

There is a solution – you need  implement IUpdatable for LINQ to SQL. This isn’t necessarily as bad as it sounds – if you can narrow down the implementation to how you are using LINQ to SQL.

MikeT had a stab at doing just this back in Dec 2007. The details are wrong (as this was based on a CTP build) – but the essence/approach he used is spot on.

  1. The DataContext is a partial class – hence implement a partial class which implements the interface IUpdatable
  2. Stub out the 12 methods of IUpdatable (When MikeT did it there were only 7!)
  3. Implement the minimum number of methods of IUpdatable you need for your project (e.g. do not implement delete if you never plan to delete). Some debugging will help you identify these.

[EDITED – Mike pointed out he revisited this more recently]

MikeT took an alternative approach in June of this year. He discussed four possible approaches (including the one outlined above) but settled on a slightly more generic approach and included an implementation for the 12 method version of IUpdatable which we ultimately shipped.

The above demonstrates that LINQ to SQL can be used effectively with Data Services. However the better approach IMHO is – switch to the ADO.NET Entity Framework!