I’m using the EntityFramework (for the first time) and have managed to get as far as querying, updating etc. I’ve got a linq query that is joining three tables, like so:
//get a list of completed orders between the last run date of this job and NOW
var completedOrders = from orders in db.orders
join orderStatus in db.orderStatus
on orders.statusID equals orderStatus.statusID
join aspnetUsers in db.aspnet_Users
on orders.userID equals aspnetUsers.UserId
into joined
where (orderStatus.statusID == 2 || orderStatus.statusID == 3 || orderStatus.statusID == 5) && (orders.dateTimeStamp > job.lastRunDate && orders.dateTimeStamp < DateTime.Now || !job.lastRunDate.HasValue)
select joined;
Then I’ve got a simply foreach loop:
foreach (var order in completedOrders)
{
//process here
}
My question is, how do I get at the information within the foreach loop? I need to get at the column data, something like:
order[“date”]
Although ideally i’d like it to be strongly typed seeing as Im using the Entity Framework.
Any feedback would be greatly appreciated.
Thanks in advance
Al
You should remove the
intoand add an anonymous type:Then you can loop through the result