#region Join 3 DataTable for Common Date with Values
public DataTable JoinDatatableForCommonData(DataTable dtTSeries, DataTable dtPcpSeries, DataTable dtSnSeries)
{
DataTable dtOutput = new DataTable("dtOutput");
try
{
//dt.Columns.Add("Station Detail Id", typeof(string));
dtOutput.Columns.Add("Date", typeof(string));
dtOutput.Columns.Add("month_year", typeof(string));
dtOutput.Columns.Add("Series1", typeof(decimal));
dtOutput.Columns.Add("Series2", typeof(decimal));
dtOutput.Columns.Add("Series3", typeof(decimal));
var result = from dtT in dtTSeries.AsEnumerable()
join dtPcp in dtPcpSeries.AsEnumerable()
on dtT.Field<string>("month_year") equals dtPcp.Field<string>("month_year")
join dtSn in dtSnSeries.AsEnumerable()
on dtT.Field<string>("month_year") equals dtSn.Field<string>("month_year")
select dtOutput.LoadDataRow(new object[]
{
dtT.Field<string>("Date"),
dtT.Field<string>("month_year"),
dtT.Field<decimal?>("Value"),
dtPcp.Field<decimal?>("Value"),
dtSn.Field<decimal?>("Value")
}, false);
//---------------copy output of result into datatable named 'dtOutput'---------------//
if (result != null && result.Count() > 0)
{
dtOutput = result.CopyToDataTable();
}
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
return dtOutput;
}
#endregion
public DataTable JoinDatatableForCommonData(DataTable dtTSeries, DataTable dtPcpSeries, DataTable dtSnSeries)
{
DataTable dtOutput = new DataTable("dtOutput");
try
{
//dt.Columns.Add("Station Detail Id", typeof(string));
dtOutput.Columns.Add("Date", typeof(string));
dtOutput.Columns.Add("month_year", typeof(string));
dtOutput.Columns.Add("Series1", typeof(decimal));
dtOutput.Columns.Add("Series2", typeof(decimal));
dtOutput.Columns.Add("Series3", typeof(decimal));
var result = from dtT in dtTSeries.AsEnumerable()
join dtPcp in dtPcpSeries.AsEnumerable()
on dtT.Field<string>("month_year") equals dtPcp.Field<string>("month_year")
join dtSn in dtSnSeries.AsEnumerable()
on dtT.Field<string>("month_year") equals dtSn.Field<string>("month_year")
select dtOutput.LoadDataRow(new object[]
{
dtT.Field<string>("Date"),
dtT.Field<string>("month_year"),
dtT.Field<decimal?>("Value"),
dtPcp.Field<decimal?>("Value"),
dtSn.Field<decimal?>("Value")
}, false);
//---------------copy output of result into datatable named 'dtOutput'---------------//
if (result != null && result.Count() > 0)
{
dtOutput = result.CopyToDataTable();
}
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
return dtOutput;
}
#endregion