I have two tables that I want to join using a linq query
Table 1 called activities has the following fields ID Code Description
Table 2 named pred has the following fields task_id pred_task_id pred_type
I want the linq query to join both tables and returns values if and only if both task_id and pred_task_id exists in Table 1.ID
I had a stab at it with no success
from pre in pred.AsEnumerable()
join act in activities.AsEnumerable()
on pre.Field<string>("task_id") equals act.Id
where (pre.Field<string>("task_id") == activity.Id)
select new
{
Pred = getTaskbyID(pre.Field<string>("pred_task_id"), activities),
Succ = getTaskbyID(pre.Field<string>("task_id"),activities),
RelationshipType = pre.Field<string>("pred_type")
});
This code does not execute what I am aiming to achieve. It returns list of all activities if the pred.task_id exist in activities.id. I want to make another filter to ensure that pred.pred_task_id also exists in the activities table.
jointoactivitieson pred.pred_task_id?pre.Field<string>("task_id")already equalactivity.Id?