How to check if object is sql to linq type

Posted by remdao on Stack Overflow See other posts from Stack Overflow or by remdao
Published on 2010-03-31T13:20:45Z Indexed on 2010/03/31 13:23 UTC
Read the original article Hit count: 588

Filed under:
|
|
|

Hi, anyone know if there's any easy way to check if an object is an sql to ling type? I have a method like this but would like it to only accept valid types.

public static void Update(params object[] items)
    {
        using (TheDataContext dc = new TheDataContext())
        {
            System.Data.Linq.ITable table;

            if(items.Length > 0)
                table = dc.GetTable(items[0].GetType());

            for (int i = 0; i < items.Length; i++)
            {
                table.Attach(items[i]);
                dc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, items[i]);
            }

            dc.SubmitChanges();
        }
    }

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#