代码之家  ›  专栏  ›  技术社区  ›  grenade

将fluent nhibernate中的子对象映射到只读视图

  •  0
  • grenade  · 技术社区  · 16 年前

    既然我正在实现一个只读UI,那么如何为它创建类映射呢 Shop

    public class Shop {
        public int Id { get; set; }
        public City City { get; set; }
    }
    
    public class City {
        public string Name { get; set; }
        public string CountryCode { get; set; }
    }
    

    public sealed class ShopMap : ClassMap<Shop> {
        public ShopMap()
        {
            Table("Shop");
            Id(x => x.Id, "ShopId");
            Map(x => x.City.Name, "CityName");
            Map(x => x.City.CountryCode, "CountryCode");
        }
    }
    

    fluent会自动实例化Shop.City吗?

    1 回复  |  直到 16 年前
        1
  •  1
  •   ChrisWue Nikesh K    13 年前

    如中所述,使用组件可能是正确的方法 fluent hibernate wiki