As a side note, it seems that this has been 
discussed<https://groups.google.com/d/topic/fluent-nhibernate/QM-X6_59rGg/discussion>on
 Fluent NHibernate group back in 2011... should have looked more closely. 
Will try to see what solutions they came up with and report back if I come 
across a way to document that for posterity.

Regards,
Dawid

On Thursday, July 12, 2012 6:13:32 PM UTC+2, SexualChocolate wrote:
>
> I'm not sure what you're doing specifically in here: 
> .Mappings(m => m.FluentMappings.AddFromAssemblyOf<
> NhibernateDatabaseConfiguration>()); 
>
> I suspect that fluent isn't recognizing the native ISet fields as sets, if 
> you're using some kind of automapping. I'm not sure how to force that with 
> fluent, but with mapping by code I do:
>
> mapper.IsSet(IsSetFieldType);
>
> private static bool IsSetFieldType(MemberInfo mi, bool declared)
>
>         {
>
>             var propertyTypeIsSet = mi.GetPropertyOrFieldType()
>
>                 .GetGenericInterfaceTypeDefinitions()
>
>                 .Contains(typeof(ISet<>));
>
>
>             if (propertyTypeIsSet) return true;
>
>
>             var backFieldInfo = 
> PropertyToField.GetBackFieldInfo((PropertyInfo)mi);
>
>
>             return backFieldInfo != null
>
>                    && backFieldInfo
>
>                           
> .FieldType.GetGenericInterfaceTypeDefinitions().Contains(typeof(ISet<>));
>
>         }
>
>
> Pretty sure I snagged the above from Jose at some point, but can't seem to 
> find from where. HTH
>
> Regards,
>
> Asher
>
> On Thu, Jul 12, 2012 at 10:26 AM, Dawid Ciecierski <
> [email protected]> wrote:
>
>> I seem to be getting the same exception, except :-) that I'm using Fluent 
>> NHibernate for configuration. Even when I set breakpoints in Set(...) or 
>> SortedSet(...) of Net4CollectionTypeFactory, these are never hit. Please 
>> see my configuratoin below:
>>
>> var sessionFactory = Fluently.Configure()
>>     
>> .Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString))
>>     .Mappings(m => 
>> m.FluentMappings.AddFromAssemblyOf<NhibernateDatabaseConfiguration>())
>>     .ExposeConfiguration(ExportSchema)
>>     .ExposeConfiguration(c => 
>> c.SetProperty(Environment.CollectionTypeFactoryClass, 
>> typeof(Net4CollectionTypeFactory).AssemblyQualifiedName))
>>     .BuildSessionFactory()
>>
>> Any idea what might be causing this?
>>
>> Best regards,
>> Dawid Ciecierski
>>
>> On Wednesday, May 11, 2011 10:30:25 PM UTC+2, Ted P wrote:
>>>
>>> José your code is working just fine. 
>>> I wasn't doing my ConfOrm:ing properly. :) 
>>>
>>> Thanks! 
>>>
>>> On 11 Maj, 21:44, Neo <[email protected]> wrote: 
>>> > Hi José, 
>>> > 
>>> > I'll download and see if I can either produce a failing test, or maybe 
>>> > find what I'm doing wrong. 
>>> > Thanks! 
>>> > 
>>> > On 11 Maj, 19:13, José F. Romaniello <[email protected]> wrote: 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > > Hi Neo again... I did a refactoring of my tests in this repository:
>>> https://bitbucket.**org/jfromaniello/nhibernate.**
>>> setfornet4/src/e6a40431.<https://bitbucket.org/jfromaniello/nhibernate.setfornet4/src/e6a40431.>..
>>>  
>>>
>>> > 
>>> > > <https://bitbucket.org/**jfromaniello/nhibernate.**
>>> setfornet4/src/f8c448b5..<https://bitbucket.org/jfromaniello/nhibernate.setfornet4/src/f8c448b5..>.>And
>>>  
>>>
>>> > > note my class:https://bitbucket.org/**jfromaniello/nhibernate.**
>>> setfornet4/src/e6a40431.<https://bitbucket.org/jfromaniello/nhibernate.setfornet4/src/e6a40431.>..
>>>  
>>>
>>> > 
>>> > > Can you break or add some failing tests? Thank you 
>>> > 
>>> > > 2011/5/11 José F. Romaniello <[email protected]> 
>>> > 
>>> > > > Weird i am using just as is! (with properties of type Iset<Foo> ) 
>>> > 
>>> > > > The source code is here: 
>>> > > >https://bitbucket.org/**jfromaniello/nhibernate.**setfornet4<https://bitbucket.org/jfromaniello/nhibernate.setfornet4>
>>> <https://bitbucket.**org/jfromaniello/nhibernate.**
>>> setfornet4/src/7f68cf01..<https://bitbucket.org/jfromaniello/nhibernate.setfornet4/src/7f68cf01..>.>
>>>  
>>>
>>> > 
>>> > > > <https://bitbucket.org/**jfromaniello/nhibernate.**
>>> setfornet4/src/7f68cf01..<https://bitbucket.org/jfromaniello/nhibernate.setfornet4/src/7f68cf01..>
>>> .>i'**ll 
>>> > > > add some tests in this repository ( i have tests on another rep. i 
>>> think) 
>>> > 
>>> > > > 2011/5/11 Neo <[email protected]> 
>>> > 
>>> > > >> 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 post to this group, send email to [email protected]. 
>>> > > >> To unsubscribe from this group, send email to 
>>> > > >> nhusers+unsubscribe@**googlegroups.com<nhusers%[email protected]>.
>>> > > >>  
>>>
>>> > > >> For more options, visit this group at 
>>> > > >>http://groups.google.com/**group/nhusers?hl=en<http://groups.google.com/group/nhusers?hl=en>
>>> .
>>
>>  -- 
>> 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/-/L_52GHTxUcEJ.
>> 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.
>>
>
>

-- 
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/-/UhyMxI28axsJ.
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