Private collection mapping in fluent nhibernate

前端 未结 3 430
日久生厌
日久生厌 2020-12-17 01:22

How can I map this:

public class Customer
{
   private IList _orders;
   public IEnumerable 
   GetAllOrders()
   {
      return _o         


        
3条回答
  •  自闭症患者
    2020-12-17 01:28

    You can map a completely private collection using Reveal.Member(), but it has a specific and non-obvious restriction: the Expression that HasMany() accepts has to return either IEnumerable or object.

    For your class:

    public class Customer
    {
        private IList _orders;
        public IEnumerable GetAllOrders()
        {
            return _orders;     
        }
    }
    

    the following line will populate the _orders collection:

    HasMany(Reveal.Member>("_orders"));
        //additional mapping behaviors
    

    For completeness - the following line gives a compiler error:

    HasMany(Reveal.Member>("_orders"));
    

提交回复
热议问题