Getting “unable to cast PersistentGenericSet to ISet” error

社会主义新天地 提交于 2019-12-03 01:12:56
Eranga

Your problem is you are using ISet in System.Collections.Generic namespace but nHibernate expects ISet to be Iesi.Collections.Generic.ISet<>. So change your property definition to

public virtual Iesi.Collections.Generic.ISet<People> People { get; set; }

If you want to use .net 4 ISet<> interface, go through this article

The latest NHibernate uses Iesi.Collections.ISet, not System.Collections.Generic.ISet. You can either reference the Iesi assembly or use System.Collections.Generic.ICollection:

public virtual ICollection<People> People { get; set; }

The ISet interface inherits from ICollection.

Frédéric

With Nhibernate 4, using System.Collections.Generic.ISet<> is now the way to go.

The error showcased in this question should no longer occur.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!