Home | Table Design |
Concat
This sample uses Concat to create one sequence that contains the names of all customers and Supplier, including any duplicates.
DataClassesDataContext db = new DataClassesDataContext();
LINQ:
var Customer = from c in db.Customers
select c.Name;
var Supplier = from s in db.Suppliers
select s.Name;
var allName = Customer.Concat(Supplier);
Lambda:
var allName = db.Customers.Select(c => c.Name)
.Concat(db.Suppliers.Select(s => s.Name));
Console.WriteLine("Customer and Supplier names:");
foreach(var n in allName)
Response.Output.WriteLine("{0}<br> ", n);
Result:
Rachit Rokad
Poonam Makati
Ayush Patel
Nenshi
Yuti Vachani
Rachit Rokad
Vimal Patel
Parul Makadiya
Aarti Chapani
==============================
Shradhdha Zalavadiya |Senior Software Engineer
WebMingle Technology
Accelerated by knowledge. Driven by values.
www.webMingle.in
No comments:
Post a Comment