WPF Reflections

Feb 27 2008   2:46PM GMT

Save ObservableCollection to Linq for Sql

Mark Shurmer Profile: MarkWPF

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

3  Comments on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.
  • Mrbiancardi
    is not possible to use LINQ + Microsoft Blend ?
    0 pointsBadges:
  • MarkWPF
    Re: LINQ and Blend You can create a data context binding in Blend and set it to your class that exposes the EntitySet class
    15 pointsBadges:
  • Rachid2008
    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.
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: