SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Combining IQueryables?

    I have three methods that return IQueryables. Each from a different table. I'd like to be able to combine them into one IQueryable but I can't seem to think of a way to accomplish it. The reason I want to do that is so that I can orderby them all together instead of separately and then use the final result as a ListView DataSource.

  2. #2
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Concat method will do what your looking for: http://msdn.microsoft.com/en-us/library/bb351755.aspx

  3. #3
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dhtmlgod View Post
    The Concat method will do what your looking for: http://msdn.microsoft.com/en-us/library/bb351755.aspx
    I thought so, too. I must be doing something wrong. I'll try again.

  4. #4
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This whole thing is sloppily tossed together and perhaps I should rethink the plan from the beginning. Actually there is no real reason to have three separate tables and three separate queries. They are all the same type (IQueryable<calendarEvents>) so perhaps I can just reconfigure the database in a more planned out fashion instead of the silly way it's thrown together now.

    I do wonder why they refuse to .Concat() though. :shrug:

  5. #5
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Concat returns an IEnumerable of the two you wish to concat, it doesn't add it to the first Enumerable, so to get the resul your looking for, you need to do this:
    Code Csharp:
    var result = col1.Concat(col2);



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •