开发者

EF Change detection for pure poco

开发者 https://www.devze.com 2023-01-11 05:42 出处:网络
I have a code sample like this using (MyContainer container = new MyContainer (connectionString)) { container.ContextOptions.ProxyCreationEnabled = false;

I have a code sample like this



using (MyContainer container = new MyContainer (connectionString))
{
   container.ContextOptions.ProxyCreationEnabled = false;
   IQueryable users = from user in container.Users
                     开发者_运维知识库       where user.UserName == myuserName
                            select user;
    User claimUser = users.SingleOrDefault();
    claimUser.Preferences.Add( new Preference ....);
    container.SaveChanges();

in the mapping ' inserts/updates/deletes are mapped to stored procs.

the problem is that even though i am only adding to the preference collection here, it calls the proc for updating user, and then calls proc for inserting preference.

shouldnt it just call inserting preference proc ? since user entity didnt really change ?


You don't seem to be calling DetectChanges.

0

精彩评论

暂无评论...
验证码 换一张
取 消