NHibernate version: 1.2.0
Full stack trace of any exception that occurs:
Unable to cast object of type
'NHibernate.Collection.Generic.PersistentGenericBag`1[Projeto.Core.Domain.Armazem]' to
type 'System.Collections.Generic.List`1[Projeto.Core.Domain.Armazem]'
Name and version of the database you are using: SQL Server 2005
I have a typed collection and and trying to make it receive a list of persistent entities (mapped as a bag) but I'm getting the error mentioned above.
The error occurs on the following code:
Code:
private List<Armazem> _armazens;
public IList<Armazem> Armazens
{
set
{
_armazens = (List<Armazem>)value;
}
}
called by:
Code:
Usuario usuario = usuarioDao.GetById(codigoUsuario, false);
view.Armazens = usuario.Armazens;
Excerpt from the Usuario entity mapping:
Code:
<bag name="Armazens" inverse="false" table="usuario_armazem" lazy="true" cascade="delete">
<key column="usu_id" />
<many-to-many class="Projeto.Core.Domain.Armazem,Projeto.Core">
<column name="arm_id" />
</many-to-many>
</bag>
Thanks for any help.