OrderBy joined value : Join « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;


public class MainClass{

   public static void Main(string[] args){   
         String[] QueryString = { "One", "Two", "Three", "Four", "Five",
              "Six", "Seven", "Eight", "Nine", "Ten" };

         String[] IndexArray = { "A", "B", "C", "D", "E", "F", "G", "H", "I",
              "J", "K", "L", "M", "N", "O", "P", "Q", "R",
              "S", "T", "U", "V", "W", "X", "Y", "Z" };

         var ThisQuery = 
            from StringValue in QueryString 
            join IndexValue in IndexArray
            on StringValue.Substring(0, 1) equals IndexValue
            where Convert.ToChar(IndexValue) > 'F'
            orderby IndexValue
            select new {StringValue, IndexValue};


         foreach (var ThisValue in ThisQuery)
            Console.WriteLine(ThisValue.IndexValue + " - " + ThisValue.StringValue);



   }
}








22.8.Join
22.8.1.Join two object lists
22.8.2.Use join key word
22.8.3.Join three object list
22.8.4.Use Join on
22.8.5.Join Operator
22.8.6.Cartesian Join demo
22.8.7.Use == in join
22.8.8.Simple Join
22.8.9.OrderBy joined value
22.8.10.Join on substring