开发者

How to OrderBy in Fluent NHibernate a collection of subclassed items by a parent class property?

开发者 https://www.devze.com 2023-03-29 13:12 出处:网络
Whew.... tried to fit it all into the title there :) I have a base class/table for \"Content\" items in my CMS.I have a ContentItem subclass that has its own table, hence I map it with the SubClassMa

Whew.... tried to fit it all into the title there :)

I have a base class/table for "Content" items in my CMS. I have a ContentItem subclass that has its own table, hence I map it with the SubClassMap base.

Now, I have another class with a collection of these ContentItems. I'd like to do an OrderBy on that collection using a property "SubmittedDate" that's defined on the base class, not the subclass:

    // Collection开发者_开发百科 of items:
    HasMany(x => x.Items)
        .AsBag()
        .Cascade.AllDeleteOrphan()
        .Inverse()
        .KeyColumn("ListId")
        .LazyLoad()
        .OrderBy("SubmittedDate desc, Title asc");

However, when I try to access the collection, I get an exception stating that "SubmittedDate" was an invalid column.

Is there any way to use a column from the base class's table for a .OrderBy in FNH?

0

精彩评论

暂无评论...
验证码 换一张
取 消