I'm sure this gets asked all the time but here goes. I am having
problems figuring out how to nhib to populate a collection of
objects. I do NOT want to use the Iesi.collections. I do NOT want to
introduce a dependency on those classes throughout my application.
Is there anyway to get nhib to populate a collection with an
implementation of System.Collections.Generic.IList<T>? Surely there
is a solution to this or does everyone just reference
Iesi.Collection.ISet throughout their apps?
Below is the error I get when nhib tries to populate the Accounts
property of the User class. I am using nhib 2.1.0GA. (Account mapping
and class not shown)
ERROR:
System.InvalidCastException : Unable to cast object of type
'NHibernate.Collection.Generic.PersistentGenericSet`1
[ClaimAudit.Entity.Account]' to type
'System.Collections.Generic.IList`1[ClaimAudit.Entity.Account]'.
MY CLASS:
using System.Collections.Generic;
public class User
{
public virtual int Id {get; set;}
private IList<Account> accounts = new List<Account>();
public virtual IList<Account> Accounts {get{return accounts;}
set{accounts = value;}}
public virtual string Username {get; set;}
}
MAPPING:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Entity"
namespace="ClaimAudit.Entity">
<class name="ClaimAudit.Entity.User" lazy="false" table="users">
<id name="Id">
<generator class="native"/>
</id>
<set name="Accounts" table="user_accounts">
<key column="userid"/>
<many-to-many column="accountid" class="Account"/>
</set>
<property name="Username"/>
</many-to-one>
</class>
</hibernate-mapping>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---