Skip Ribbon Commands
Skip to main content
Navigate Up
Sign In

Quick Launch

I hear C#, I see C#, I do .NET > Posts > LINQ - preparing to transition from B2 to RTM
October 19
LINQ - preparing to transition from B2 to RTM

If you are using Orcas B2 to write your applications there is a breaking change in the Table methods for adding and removing entities.

The Add and AddAll methods are now InsertOnSubmit and InsertAllOnSubmit. The Remove and RemoveAll are now DeleteOnSubmit and DeleteAllOnSubmit.

There is a simple way to fix the problematic methods in your B2 version and make you ready for RTM thanks to new C# 3.0 extension methods feature.

First, find and replace all the usages of obsolete methods with new method signatures.  Second, add the helper class (code below) that uses extension methods to add new method signatures to the System.Data.Linq.Table used by RTM version of LINQ. When you install the RTM version you can either undef or delete this helper class.

#define LinqB2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Vertigo
{
#if LinqB2
    public static class LINQRC1Fix
    {
        public static void InsertAllOnSubmit<TEntity>(this System.Data.Linq.Table<TEntity> table, IEnumerable<TEntity> entities) where TEntity : class
        {
            table.AddAll(entities);
        }

        public static void InsertOnSubmit<TEntity>(this System.Data.Linq.Table<TEntity> table, TEntity entity) where TEntity : class
        {
            table.Add(entity);
        }


        public static void DeleteAllOnSubmit<TEntity>(this System.Data.Linq.Table<TEntity> table, IEnumerable<TEntity> entities) where TEntity : class
        {
            table.RemoveAll(entities);
        }

        public static void DeleteOnSubmit<TEntity>(this System.Data.Linq.Table<TEntity> table, TEntity entity) where TEntity : class
        {
            table.Remove(entity);
        }
    }
#endif
}

Comments

There are no comments for this post.