I have NH mapping
public class TblContentMap : ClassMap<TblContent> {
public TblContentMap() {
Table("tbl_content");
DynamicUpdate();
Id(x => x.Id).GeneratedBy.Identity().Column("id");
....
Map(x => x.ArticleType).Column("article_type").Not.Nullable();
}
}
then in my controller its mapped as
public ActionResult Save(TblContent model)
But when i call flush it throw exception.
not-null property references a null or transient value SocialDB.NDbModel.TblContent.ArticleType
Question is why? as i understand dynamic update should track which property was changed and update only that values.
PS. I know that it works if firstly get then update model
var item = MvcApplication.CurrentSession.GetContentById(model.Id);
item.Content = model.Content.StripHtml(false);
Generally it works as in EF, to use dynamic update need to select item and update fields then push it to database so it will update only modified fields.