wolli wrote:
Post your query, otherwise it's hard to tell what's going wrong.
Thanks for the promp reply.
In my case there is no explicit query. I have two connected entities.
Code:
<class name="ServiceGroup" lazy="true" table="ServiceGroup">
<id name="Id" unsaved-value="0" type="Int32" column="ID">
<generator class="native"/>
</id>
<bag name="Services" lazy="true" table="Service" cascade="all-delete-orphan" fetch="subselect" inverse="true" generic="true" order-by="Name asc">
<key column="Ref_GroupID" />
<one-to-many class="BaseService" />
</bag>
........
</class>
<class name="BaseService" polymorphism="explicit" lazy="true" table="Service">
<many-to-one name="Group" column="Ref_GroupID" class="ServiceGroup" />
<many-to-one name="Product" column="Ref_ProductID" class="BaseProduct" />
<!-- BaseProduct is base entity -->
<joined-subclass ........ />
<joined-subclass ........ />
<joined-subclass ........ />
</class>
I got next error when I was trying to traverse ServiceGroup.Services:
System.InvalidCastException:
Unable to cast object of type 'CProxyTypesampai_ProductBaseServiceProduct_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2' to type 'Service'.
In debugger I saw that some objects of the collection were of the right type, but some was of the type noticed in the exception message.
The problem appears on SQL Server 2005, 2008 while on SQL 2K works fine.