Feb 21 2008

LINQ to SQL Beta 2 to RTM Changes

Category:Bil@l @ 23:43

I had a LINQ to SQL code for one of my article coming soon in a magazine where I wrote the code during the Beta 2 of the LINQ to SQL. Now when I try to run the same code on VS 2008 I got errors on the "Add" and "Remove" method of the entities inside the DataContext.

For example:

            // Create a new instance of the DataContext
            CustomerDataContext db = BizObject.Context;

            // Create a new customer and add it to the DataContext
            // to be able to have the DataContext track changes on the object
            Customer localCustomer = new Customer {
                    FirstName = customer.FirstName,
                    LastName = customer.LastName,
                    Email = customer.Email
            };
           
            // Add the item to the DataContext           
            db.Customers.InsertOnSubmit(localCustomer);

There is no Add method anymore, it got replaced with InsertOnSubmit method, Same applies to the Remove method, it was replaced by DeleteOnSubmit method. For a complete list of the changes, visit this link on the MSDN forums:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2060651&SiteID=1

 

Hope this helps you,
Regards

Tags:

Comments are closed