In my application there are many cases where I have to update one single property of an entity in the database. In the internet I've read that DynamicUpdate()
should change the behaviour of Fluent NHibernate so it does only update the properties != null
So I wrote my mapping like this:
public class Building
{
public virtual Guid Id { get; set; }
public virtual int ConstructionPhase { get; set; }
public virtual string Name { get; set; }
[some other properties]
}
public class BuildingMap : ClassMap<Building>, IMappedEntity
{
public BuildingMap()
{
DynamicUpdate();
SelectBeforeUpdate();
Id(x => x.Id);
Map(x => x.ConstructionPhase);
Map(x => x.Name);
[some other properties]
}
}
But if I try to update an entity and leave the name
property empty, the name is deleted in the database.
Do I have to configure Fluent NHibernate in an other way, or what's the problem?