Fluent NHibernate Mapping a column against one of two columns

前端 未结 1 348
情歌与酒
情歌与酒 2021-01-24 16:37

I\'m dealing with some legacy vendor code that I can\'t modify. I\'d like to wrap the database with an abstraction layer that is easier to use.

Given the following two

1条回答
  •  终归单人心
    2021-01-24 17:22

    It's not elegant, but I finally came up with the following:

    public class Process
    {
        public virtual IList SourceRoutes { get; set; }
        public virtual IList DestinationRoutes { get; set; }
    }
    
    public class ProcessOverride : IAutoMappingOverride
    {
        public void Override(AutoMapping mapping)
        {
            mapping.HasMany(proc => proc.SourceRoutes).Table("Routes").KeyColumn("SourceID");
            mapping.HasMany(proc => proc.DestinationRoutes).Table("Routes").KeyColumn("DestID");
        }
    }
    

    0 讨论(0)
提交回复
热议问题