Fluent NHibernate mapping

后端 未结 5 1758
天涯浪人
天涯浪人 2021-02-06 02:21

I\'m new to NHibernate and Fluent NHibernate.

Assuming I have a situation like the following

Table Activities (uniquidentier ID, varchar ActivityName)
Ta         


        
5条回答
  •  不知归路
    2021-02-06 02:32

    A colleague pointed e to this site.

    Based on that discussion, I've come to

    Table("Activities");
            Id(x => x.Id).Column("ID").GeneratedBy.Guid();
            Map(x => x.ActivityName).Not.Nullable().Length(50);
            HasMany(x => x.ActivityParameters)
                .KeyColumn("ActivityID")
                .AsMap(idx => idx.Column("ParameterName"), elem => elem.Column("ParameterValue"))
                .Not.LazyLoad()
                .ForeignKeyCascadeOnDelete()
                .Table("ActivityParameters");
    

    I have to test this.

提交回复
热议问题