I want to convert the LINQ Join query result into the DataTable for which I have checked but couldn't found any authentic solution.
I have tried to do it two ways 1:
var query = from A in ABC.AsEnumerable()
join X in XYZ.AsEnumerable()
on A.Field<int>("A-ID") equals
X.Field<int>("X-ID")
where ((A.Field<string>("A-Column1") == "1")
&& (r.Field<string>("X-Column1") == "1"))
select new
{
UserName = ABC.Field<string>("UserName"),
UserExperience = XYZ.Field<string>("UserExperience"),
...
};
2:
DataTable dt = new DataTable();
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("UserExperience", typeof(string));
var query = from A in ABC.AsEnumerable()
join X in XYZ.AsEnumerable()
on A.Field<int>("A-ID") equals
X.Field<int>("X-ID")
where ((A.Field<string>("A-Column1") == "1")
&& (r.Field<string>("X-Column1") == "1"))
select dt.LoadDataRow(new object[]
{
ABC.Field<string>("UserName"),
XYZ.Field<string>("UserExperience"),
...
}, false);
DataTable ddt = new DataTable();
ddt = query.CopyToDataTable();
But that both couldn't resolve my problem.
I want to convert that result into the DataTable / DataSet.
Thanks in advance.