WPF Reflections

Feb 27 2008   2:46PM GMT

Save ObservableCollection to Linq for Sql



Posted by: Mark Shurmer
WPF

I described how you create an ObservableCollection from a Linq query (including Linq for Sql amongst others) in a previous post.

A second part of the equation is of course, how do you then save your changes back to the database using Linq?

Of course, you have probrably guessed that it’s not going to be a walk in the park.
What you need to do is go through the object and all sub lists and convert them back into the Linq EntitySet classes. After that they can be saved via SubmitChanges.

Tedious, you bet!
Either I’m missing the point somewhere or the EntityFramework needs to fix this by implementing INotifyCollectionChanged in the EntitySet class

Comment on this Post


You must be logged-in to post a comment. Log-in/Register

Mrbiancardi  |   Feb 28 2008   10:50AM GMT

is not possible to use LINQ + Microsoft Blend ?


 

MarkWPF  |   Feb 28 2008   11:30AM GMT

Re: LINQ and Blend

You can create a data context binding in Blend and set it to your class that exposes the EntitySet class


 

Rachid2008  |   Mar 3 2008   9:16AM GMT

hi mark, thank for you wonderful tips. Actually i want to use linq and wpf in my project and i did not found a great tutorial that explain how to bind wpf forms with linq to sql. I mean a CRUD application involving linq to sql and wpf(expression blend). Have you an idea where can i find such tutorials. Thanks very much again for your great solution.