WPF Reflections

Feb 27 2008   2:46PM GMT

Save ObservableCollection to Linq for Sql



Posted by: MarkWPF
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

Leave a comment:

Mrbiancardi  |   Feb 28, 2008  10:50 AM (GMT)

is not possible to use LINQ + Microsoft Blend ?


 

MarkWPF  |   Feb 28, 2008  11:30 AM (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:16 AM (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.