c# - How did I wrong my DataContext? -


i've been working linq sql time now, , in solution following:

  • in project create dbml schema.
  • in project create simple dataaccesslayer (dal) knows first project, , instantiates datacontext.
  • in 3rd project (business logic) instantiate dal.

this works well. however, time, don't know why, "it" doesn't work. "it" being "me updating database". changed code around tests, , result don't understand.

mydatacontext datacontext = new mydatacontext(myconnectionstring); databaseitem dbi = (from item in datacontext.databaseitems     item.id == 1     select item).first(); dbi.name= "toto"; // datacontext.getchangeset() tells me nothing changed. 

i dug deeper breaking bdi.name = "toto"; , compared similar value assignment in project works (both designer generated code) , saw code missing (i wrote them down there, commented them see missing) :

[column(storage="_name", dbtype="nvarchar(250)")] public string name {         {         return this._name;     }     set     {         if ((this._name!= value))         {             //this.onlayoutchanging(value);             //this.sendpropertychanging();             this._name= value;             //this.sendpropertychanged("name");             //this.onlayoutchanged();         }     } } 

anyone can tell me how come these lines missing, , did messed up?

when datacontext.refresh(refreshmode.keepchanges, datacontext.databaseitems);, error:

an object specified refresh not recognized.

if objects not have primary key, objects not tracked changes. probable id not set primary key in dbml.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -