开发者

subsonic 2.2 : how to order a collection by FK Title?

I'm stuck with the following scenario, i have 2 tables called (Products and Categories). the field CategoryID in Products table has a FK to the Categories table.

Now for my data table in my CMS I'm looking for a way to sort the products based on the Category Title. This Title is available when I'm looking at a DAL.Product item but ofcourse not when I'm querying the products table.

Is this possible using native Subsonic or do I开发者_运维知识库 need to create a detour? I could just sort them on the CategoryID but that is not so straightforward for the end-users cause all other columns can be sorted alphabeticly.

Kind regards ans thanks for your time, Mark

ps: I'm getting paged results so sorting the collection after it's filled is not an option for me...


You may try something along those lines.

List<DAL.Product> lst = DAL.DB.Select().From<DAL.Product>()
    .InnerJoin<DAL.Category>
    .OrderAsc(DAL.Category.CategoryTitleColumn.ColumnName)
    .Paged(x,y)
    .ExecuteTypedList<DAL.Product>();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜