Question

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"));
            });
    }
}
Was it helpful?

Solution

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");
                                    }));
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top