countrymeister
asked on
How to orderby a linq query with a join to two tables and output the data to a predefined datatable
I need to order this linq query by ID and then by Date
I have two datatables dt1 and dt2
and then I have a predefined table called joinedTable with columns ID, Code, Date, Price
DataTable joinedTable = GetDataTable();
var result = from dataRows1 in infocodesDT.AsEnumerable()
join dataRows2 in mqDT.AsEnumerable()
on dataRows1["InfoCode"] equals dataRows2["InfoCode"]
select joinedTable.NewRow().ItemA rray = new object[]{
dataRows1["SecurityID"],
dataRows2["MarketDate"],
dataRows2["OpenPrice"],
dataRows2["ClosePrice"],
dataRows2["VWAP"],
dataRows2["TotalReturnInde x"],
};
I have two datatables dt1 and dt2
and then I have a predefined table called joinedTable with columns ID, Code, Date, Price
DataTable joinedTable = GetDataTable();
var result = from dataRows1 in infocodesDT.AsEnumerable()
join dataRows2 in mqDT.AsEnumerable()
on dataRows1["InfoCode"] equals dataRows2["InfoCode"]
select joinedTable.NewRow().ItemA
dataRows1["SecurityID"],
dataRows2["MarketDate"],
dataRows2["OpenPrice"],
dataRows2["ClosePrice"],
dataRows2["VWAP"],
dataRows2["TotalReturnInde
};
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does this, select joinedTable.NewRow().ItemA rray = new object[]{, actually work on your system?
ASKER
Yes, that works, and so does the last linq query I posted with the order by.
I do not have to create that extra class. Give it a try and let me know.
I do not have to create that extra class. Give it a try and let me know.
ASKER
I did not have to create a new class