开发者

Why HashedSet forces loading lazy collection?

开发者 https://www.devze.com 2023-04-06 18:51 出处:网络
I query items with lazy collections in via nHibernate. Items are queried without fetching collections. But when i try to create HashedSet

I query items with lazy collections in via nHibernate. Items are queried without fetching collections. But when i try to create HashedSet

var hashedSet = new HashedSet<Thing>(Session.Query<Thing>()) 

from those items all lazy stuff is fetched. Whats causing that?

 [Serializable]
    public class Thing {
        public virtual String Name { get; set; }       
        public Thing() {
            OtherThings = new HashedSet<OtherThing&开发者_如何学Gogt;();              
        }

        public virtual ISet<OtherThing> OtherThings { get; set; }
  }


Maybe you have overridden GetHashCode() in the entity (or any base class of it) and access the properties there?

0

精彩评论

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