Tuesday, 23 October 2007

Changes to System.Data.Linq.ChangeSet and System.Data.Linq.Table from VS 2008 Beta 2 to RTM

Just installed VS 2008 release candidate, and there were some compile issues related to the System.Data.Linq.ChangeSet class. One of the changes that affected me in the upgrade was the move to move "Database mindset" language. I found this move from "ModifiedEntity" to "Updates" unusual because it is terminology brought from the database field. There is also a change to System.Data.Linq.Table where the "Add" method is now "InsertOnSubmit". The "Remove" method is now "DeleteOnSubmit". Seems like a throwback to me!

Another issue is that my LINQ dbml files had conversion issues, showing the error:
"There is no Unicode byte order mark. Cannot switch to Unicode." The fix was just to remove the encoding attibute in the XML document description:

<?xml version="1.0" encoding="utf-16"?>



public bool Run(ChangeSet changedObjects)
{
List<trackedobject> tracked = new List<trackedobject>();
foreach (object o in changedObjects.AddedEntities)
tracked.Add(new TrackedObject { Current = o, IsNew = true });
foreach (object o in changedObjects.ModifiedEntities)
tracked.Add(new TrackedObject { Current = o, IsChanged = true });
foreach (object o in changedObjects.RemovedEntities)
tracked.Add(new TrackedObject { Current = o, IsDeleted = true });
return Run(tracked);
}

needs to change to:


public bool Run(ChangeSet changedObjects)
{
List<TrackedObject> tracked = new List<TrackedObject>();

foreach (object o in changedObjects.Inserts)
tracked.Add(new TrackedObject { Current = o, IsNew = true });
foreach (object o in changedObjects.Updates)
tracked.Add(new TrackedObject { Current = o, IsChanged = true });
foreach (object o in changedObjects.Deletes)
tracked.Add(new TrackedObject { Current = o, IsDeleted = true });

return Run(tracked);
}

No comments: