I am facing a problem in populating datagrid using linq.
I have three tables:
Table1, Table2, Table3
Table1 has columns : date, machine_name
Table2 has columns : date, machine_name, defect
Table3 has columns : date, machine_name, status
1. In service.svc, I am not able to join these three table on basis of date
Table1: date | machine_name
1/1/2012 | AAAA
2/1/2012 | BBBB
Table2: date | machine_name | defect
1/1/2012 | AAAA | gear break
2/1/2012 | BBBB | shaft break
2/1/2012 | BBBB | spline break
Table3: date | machine_name | status
1/1/2012 | AAAA | not working
2/1/2012 | BBBB | still working
After Joining Final table should display result:
Table1 Table2 Table3
date | machine_name | defect | status
1/1/2012 | AAAA | gear break | not working
2/1/2012 | BBBB | shaft break | still working
2/1/2012 | BBBB | spline break | still working
2.) How to use collection and how to specify return type so it could be bind to datagrid
Thanks
Raman
Jignesh TrivediPosted Apr 8, 2012, 11:46 PM
First create custom class like
public class myCustomData
{
public DateTime Date { get; set; }
public string MachineName { get; set; }
public string Defect { get; set; }
public string Status { get; set; }
}
both the side silver light and wcf or RIA.
try following query.
var mydata = (from t1 in table1
join t2 in table2 on new { t1.MachineName, t1.Date } equals new { t2.MachineName, t2.Date }
join t3 in table3 on new { t1.MachineName, t1.Date } equals new { t3.MachineName, t3.Date }
select new myCustomData
{
Date = t1.Date,
MachineName = t1.MachineName,
Defect = t2.Defect,
Status = t3.Status
}).ToArry();
this query is convert in Array
and return type is myCustomData[]
hope this help.