开发者

Mapping child objects in fluent nhibernate to a read-only view

开发者 https://www.devze.com 2022-12-29 17:15 出处:网络
Given that I am implementing a read-only UI, how do I create a ClassMap for Shop: public class Shop { public int Id { get; set; }

Given that I am implementing a read-only UI, how do I create a ClassMap for 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; }
}

The DB interface for Shops is a View containing 3 columns (ShopId, CityName, CountryCode). I was hoping to do something like this:

public sealed class ShopMap : ClassMap<Shop> {
    public ShopMap()
    {
        Table("Shop");
        Id(x => x.Id, "ShopId");
        Map(x => x.City.N开发者_运维问答ame, "CityName");
        Map(x => x.City.CountryCode, "CountryCode");
    }
}

Will fluent auto-instantiate Shop.City?


Using a component might be the proper way as described in the fluent hibernate wiki

0

精彩评论

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