0
在WPF應用程序中,我使用LINQ to SQL類(由SQL Metal創建,因此實現了POCO)。Linq to SQL EntitySet綁定MVVM的方式
我們假設我有一個表User和一個Table Pictures。這些圖像被實際從一個圖像創建的,它們之間的差可以是大小,着色,...
所以每次用戶可以具有多於一個的圖片,所以關聯是1:N(用戶:圖片)。
我的問題:
一)如何綁定,在MVVM方式,畫面控制到一個圖片(我需要一個特定的畫面)在EntitySet的,表現出來呢?
b)每當用戶改變她的照片時,整個EntitySet應該被扔掉,新創建的圖片應該被添加。這是正確的方法嗎?
例如
//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()
在此先感謝