문제

I am building my applicaiton using nhibernate 3.2 and s#arp lite framework.

table "Stack" :

Id: int (PK)

Title: string

PostBy: int (FK, User table Id)

I am using automapping, by convention its looking for UserID which does not exist. I need to override this.

here's my code, it doesn't work, please help me to fix it.

internal class StackOverride : IOverride
{
    public void Override(ModelMapper mapper)
    {
        mapper.Class<Stack>(s =>
            {
                s.Property(x => x.PostBy, map => map.Column("PostBy"));
            });
    }
}
도움이 되었습니까?

해결책

finally figure it out how to do it. here's the code.

   public void Override(ModelMapper mapper)
    {
        mapper.Class<Stack>(map => 
            map.ManyToOne(
                        x => x.PostBy, 
                        manyToOne => 
                                    {
                                        manyToOne.Column("PostBy");
                                    }));
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top