Override default Fluent NHibernate Column Mapping

白昼怎懂夜的黑 提交于 2019-12-24 02:25:06

问题


I am trying to find the syntax for changing the automap behavior of Fluent NHibernate.

How would I modify the code below to map the UserId property to a column named UserIdentifier (as an example)?

public class MyTypeMap : ClassMap<MyType>
{
    public MyTypeMap()
    {
            Table("MyTypes");
            Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty);
            Map(x=> x.UserId);
    }
}

Thanks


回答1:


public class MyTypeMap : ClassMap<MyType>
{
    public MyTypeMap()
    {
            Table("MyTypes");
            Id(x => x.InstanceId).GeneratedBy.Guid().UnsavedValue(Guid.Empty);
            Map(x=> x.UserId).Column("UserIdentifier");
    }
}



回答2:


public class MyTypeMap : ClassMap<MyType>
{
   public MyTypeMap()
   {
        Id (x => x.InstanceId).Column ("UserIdentifier").GeneratedBy.Guid().UnsavedValue(Guid.Empty);
   }
}


来源:https://stackoverflow.com/questions/1940462/override-default-fluent-nhibernate-column-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!