I encountered a problem when doing a projection like this:

Projections.Conditional(
  Restrictions.Eq("parentClassAlias.class", typeof(SubClass1)),
  Projections.Property(() => ((SubClass1)parentClassAlias).StringProperty1),
  Projections.Property(() => ((SubClass2)parentClassAlias).StringProperty2))

That is, suppose I have three classes: ParentClass, SubClass1 and 
SubClass2; SubClass1 and SubClass2 inherit from ParentClass. In my 
projection I want to return a value of type 'string' but from different 
properties, depending on the type of the entity. The problem is that 
StringProperty1 has length 128 and StringProperty2 has length 64. This 
causes a runtime exception from NHibernate:

NHibernate.HibernateException : Both true and false projections must return 
the same types.
But True projection returns: [NHibernate.Type.StringType] 
And False projection returns: [NHibernate.Type.StringType]

This is due to the fact that StringType equality comparison takes into 
account the lengths, so ConditionalProjection.GetTypes() throws because 
trueTypes[i].Equals(falseTypes[i]) 
== false.

Has anybody had such problem and know a work-around or maybe a completely 
different solution for my needs?

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