Setting CollectionTypeFactory must be done before adding mappings 
assemblies. 
Have a look at my following request:  
https://groups.google.com/forum/?fromgroups#!topic/nhusers/BWjeHAiu4h4 

On Wednesday, May 11, 2011 5:49:30 PM UTC+2, NeoDarque wrote:
>
> I'm looking into José Romaniello's Net4Collections class to use the 
> BCL HashSet instead of the iesi HashedSet, but I'm getting an 
> exception when my model looks like this: 
>
> public class Survey 
> { 
>     public virtual string Name { get; set; } 
>     public virtual ISet<Question> Questions { get; set; } 
>
>     public Survey() { 
>         this.Questions = new HashSet<Question>(); 
>     } 
> } 
>
> Whenever I try to save a new Survey with a populated Questions 
> collection I get an exception saying: 
> {"Unable to cast object of type 
> 'NHibernate.Collection.Generic.PersistentGenericSet`1[Demo.Models.Question]' 
>
> to type 'System.Collections.Generic.ISet`1[Demo.Models.Question]'."} 
>
> But if I expose my Questions property like "ICollection<Question>" it 
> works fine. 
>
> And yes, I have 
> "configure.Properties[NHibernate.Cfg.Environment.CollectionTypeFactoryClass] 
>
> = typeof(Net4CollectionTypeFactory).AssemblyQualifiedName;". 
>
> This is with the latest alpha of NHibernate 3.2. 
>
> I have no problems sticking with ICollection<> but just wondering if 
> I'm missing something to get it to work. 
>
> Cheers! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/otFKEBPTIPIJ.
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.

Reply via email to