Nhibernate/Linq: NHibernate.QueryException : could not resolve property: Profile.class of: MyNamespace.MyObject

后端 未结 1 392
难免孤独
难免孤独 2021-01-21 20:26

I\'m having an issue with my linq query. I am trying to filter objects based on selected values. We use a query model which returns a System.Linq.Expressions.Expression and use

相关标签:
1条回答
  • 2021-01-21 20:45

    I'm pretty sure NHibernate.Linq does not support filtering on class type directly. If you need to distinguish between the types, I would use a property value on the base class (probably an enum) that is set to the proper value in the child classes. You can then perform your comparison like this:

    x.Post.Profile.Type = ProfileTypes.BusinessProfile
    

    Just set this property statically in the constructor for the child classes, map it with NHibernate, and set update=false for the property mapping. Although somewhat inelegant, this should give you the results you're looking for.

    0 讨论(0)
提交回复
热议问题