开发者

EF Change detection for pure poco

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜