Reputation: 23
I did one small application of contact system for add update and delete.Now making group of this contacts here I am using XML as datasource.Now want to join two xml files one contact.xml and other is group.xml.
I got this really useful.
DataSet ds1 = new DataSet(); DataSet ds2 = new DataSet();
ds1.ReadXml("Contact.xml");
ds2.ReadXml("Group.xml");
DataTable dt1 = ds1.Tables[0];
DataTable dt2 = ds2.Tables[0];
var groups = from contact in dt.AsEnumerable()
join ol in dt1.AsEnumerable()
on contact.Field<string>("ID") equals ol.Field<string>("ID")
select new
{ FName=ol.Field<string>("FName")
};
Upvotes: 2
Views: 1972
Reputation: 14781
Simply this way:
var q = from c in customers
join o in orders on c.Key equals o.Key
select new {c.Name, o.OrderNumber};
Refer to the following tutorial about LINQ:
http://www.asp.net/linq/videos
Upvotes: 2