I have two lists List<WorkOrder>
and List<PlannedWork>
I would like join the two lists on the workorder number as detailed below. In other words I have a list of planned work but I need to know the description of the work for the workOrderNumber.
I am new to both linq and lambda expressions, and I haven't quite got my head wrapped around them yet.
class WorkOrder { public int WorkOrderNumber { get; set; } public string WorkDescription { get; set; } } class PlannedWork { public int WorkOrderNumber { get; set; } public DateTime ScheduledDate { get; set; } }
The way to do this using the Extention Methods, instead of the linq query syntax would be like this:
var results = workOrders.Join(plans, wo => wo.WorkOrderNumber, p => p.WorkOrderNumber, (order,plan) => new {order.WorkOrderNumber, order.WorkDescription, plan.ScheduledDate} );
It sounds like you want something like:
var query = from order in workOrders join plan in plans on order.WorkOrderNumber equals plan.WorkOrderNumber select new { order.WorkOrderNumber, order.Description, plan.ScheduledDate };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With