Concatenation Operator Example in C# LINQ

public List<Customer> CustomerList; 
StringBuilder sbResult = new StringBuilder();
var Query12 = CustomerList.Where(c => c.Country == "USA")
                          .Concat(CustomerList.Where(c => c.Country == "Canada")
                          .Concat(CustomerList.Where(c => c.Country == "Mexico")));
 
Query12 = (from c in CustomerList
           where c.Country == "USA"
           select c)
           .Concat((from c in CustomerList
           where c.Country == "Canada"
           select c)
           .Concat((from c in CustomerList
           where c.Country == "Mexico" 
           select c)));
 
foreach (var c in Query12)
    sbResult.Append(String.Format("CustID = {0}, Name = {1}, Country = {2}\r\n",
    c.CustomerID, c.CompanyName, c.Country));
Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker