Re: Linq. OrderBy and Where.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marc Gravell

    Re: Linq. OrderBy and Where.

    It isn't clear what Source is here - is this a property of a Tag? If
    there are both File and Post records in the set, how do you sort it?

    You can union LINQ queries, so you might have

    var qry1 = from t in database.Tags
    where t.Source == "File" && t.FileCount != 0
    orderby t.FileCount
    select new {...};
    var qry2 = from t in database.Tags
    where t.Source == "Post" && t.PostCount != 0
    orderby t.PostCount
    select new {...};

    var final = qry1.Union(qry2 ).ToList();

    (untested for obvious reasons)

    Marc
Working...