title: Linq to SQL EntitySet Binding the MVVM way
body: <p>In a WPF application i'm using LINQ to SQL classes (created by SQL Metal, thus implementing POCOs).</p>
  
  <p>Let's assume i have a table User and a Table Pictures. These pictures are actually created from one picture, the difference between them may be the size, coloring,... </p>
  
  <p>So every user may has more than one Pictures, so the association is 1:N (User:Pictures).</p>
  
  <p><strong>My problems</strong>: </p>
  
  <p><strong>a)</strong> how do i bind, in a MVVM manner, a picture control to one picture (i will take one specific picture) in the EntitySet, to show it up?</p>
  
  <p><strong>b)</strong> everytime a user changes her picture the whole EntitySet should be thrown away and the newly created Picture(s) should be a added. Is this the correct way?</p>
  
  <p>e.g. </p>
  
  <pre><code>//create the 1st piture object
  UserPicture1 = new UserPicture();
  UserPicture1.Description = "... some description.. ";
  USerPicture1.Image = imgBytes; //array of bytes
  
  
  //create the 2nd piture object
  UserPicture2 = new UserPicture();
  UserPicture2.Description = "... another description.. ";
  UserPicture2.Image = DoSomethingWithPreviousImg(imgBytes); //array of bytes
  
  
  //Assuming that the entityset is called Pictures
  //add these pictures to the corresponding user
  User.Pictures.Add(UserPicture1);
  User.Pictures.Add(UserPicture2);
  
  
  //save changes 
  datacontext.Save()
  </code></pre>
  
  <p>Thanks in advance</p>