2009-06-24 9 views
0

私はこのNHibernateは基準APIの予測は

public class Customer 
{ 
    public Customer() { Addresses = new List<Address>(); } 
    public int CustomerId { get; set; } 
    public string Name { get; set; } 
    public IList<Address> Addresses { get; set; } 
} 

のようなものであるエンティティを持っていると私はこのような基準APIを使用して、それを照会しようとしています。

ICriteria query = m_CustomerRepository.Query() 
    .CreateAlias("Address", "a", NHibernate.SqlCommand.JoinType.LeftOuterJoin); 
var result = query 
    .SetProjection(Projections.Distinct(
    Projections.ProjectionList() 
     .Add(Projections.Alias(Projections.Property("CustomerId"), "CustomerId")) 
     .Add(Projections.Alias(Projections.Property("Name"), "Name")) 
     .Add(Projections.Alias(Projections.Property("Addresses"), "Addresses")) 
    )) 
    .SetResultTransformer(new AliasToBeanResultTransformer(typeof(Customer))) 
    .List<Customer>() as List<Customer>; 

このクエリを実行すると、CustomerオブジェクトのAddressesプロパティはnullになります。とにかくこのListプロパティの投影を追加しますか?

答えて

0

コードが良好であるようです。したがって、問題はAddressesプロパティのマッピングにある可能性があります。

関連する問題