Accepted answer

This should work.

var query = from stk in V_InStock
            group stk by stk.PartNo into stkg
            where stkg.Key == '100-25897'
            select new
              ModulePartNo = stkg.Key,
              Available = stkg.Sum(s => s.Delivered) - stkg.Sum(s => s.Allocated)


If you need to do aggregate grouping etc you will probably need to set up an object to "select" everything into. However for a straight join something like this should work.

  var outputObject = (from t1 in dbContext.table1
  join t2 in dbContext.table2 on t1.PartNo equals t2.PartNo
  select (t1.Delivered - t2.Allocated));

Related Articles