开发者

FluentNhibernate automapping a tree (recursive association)

I'm trying to automap a class Code. Codes can have (Sub)Codes.

 public class Code
 {
    public virtual string Key{get;set;}
    public virtual Code Parent{get; set;}
    public virtual ICollection<Code> SubCodes{get;set;}
    private ICollection<Code> subCodes = new Collection<Code>();
 } 

This works but I get column IdParent and an IdCode column in my table. Naming the Parent property IdCode doesn't help then I get an IdIdCode colum开发者_运维问答n and the IdCode

What do I need to do to fix this.

I use Automapping with a Configuration object


Seems like your automapping uses a convention that added the prefix Id to references as well as to the Id.

If you want, You can override this convention by using your own custom ForeignKeyConvention in the AutoMap configuration.

otherwise, just name your db table columns accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜