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

Posted by grenade on Stack Overflow See other posts from Stack Overflow or by grenade
Published on 2010-05-04T14:43:06Z Indexed on 2010/05/11 9:04 UTC
Read the original article Hit count: 292

Filed under:
|

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.Name, "CityName");
        Map(x => x.City.CountryCode, "CountryCode");
    }
}

Will fluent auto-instantiate Shop.City?

© Stack Overflow or respective owner

Related posts about c#

Related posts about fluent-nhibernate