I’ve dived into this post (which is excellent and I hope gets expanded) on dealing with LINQ. Unfortunately I am having trouble fitting everything together. My current thoughts:
- I will use a for-each on the unique list of employees (Primary/Foreign key is “ID”).
- The LINQ will then need to check the other data table. dt_SalesActivity.asEnumerable().where(dt_SalesActivity.rows(“ID” = ID) //should downselect to rows that match that ID
- Somehow access the “amounts” column for those rows, and then perform a LINQ .sum operation on them, which will return a double.
- Assign double to the related row in the Employee table
I have some limited confidence in step 2, but no confidence in step 3. All the examples I’ve seen seem to use sum on the direct result returned by other LINQ queries. I’ll admit I’m having a bit of trouble wrapping my head around the length of some of these statements and figuring out exactly where “I am” within the relevant data structures/code.
If this was SQL, I think it’d be:
Select Sum(Amount) from SalesActivity
Where ID = Input_ID