I am having a hell of a time trying to figue out groupings on data tables with LINQ. I am using VB
I have two data tables. I'll define from
Table Law = columns (ven_grp,comp_no,acct_unit,description,company)
Table Comps = columns(comp_parent,comp_struct1, comp_struct2, .... through comp_struct9
Now here is the SQL equivalent of what I need in LINQ
SELECT [ven_grp], xx_lawTemp.[comp_no],[acct_unit],[description],[company]
FROM xx_lawTemp inner join
companies ON xx_lawTemp.company = companies.comp_struct1 and xx_lawTemp.ven_grp = companies.comp_parent
group by [ven_grp], xx_lawTemp.[comp_no],[acct_unit],[description],[company]
For reasons I won't get into I can't use SQL to do what I need to do.
this is how far I got with LINQ
Dim query = From l In law, c In comps _
Where l("ven_grp") = c("comp_parent") And l("company") = c("comp_struct1") _
Select l
which works ok, but I can't for the life of me figure out how to group on the fields I need to and then dump the query results into datatable. i need to follow the groupings that are in the SQL query above. I've looked at tons of examples on line and I just don't seem to get it or it does not work the way examples show. Both of my tables are defined as similar "Dim law = ds.tables(0).asenumerable()
I have two data tables. I'll define from
Table Law = columns (ven_grp,comp_no,acct_unit,description,company)
Table Comps = columns(comp_parent,comp_struct1, comp_struct2, .... through comp_struct9
Now here is the SQL equivalent of what I need in LINQ
SELECT [ven_grp], xx_lawTemp.[comp_no],[acct_unit],[description],[company]
FROM xx_lawTemp inner join
companies ON xx_lawTemp.company = companies.comp_struct1 and xx_lawTemp.ven_grp = companies.comp_parent
group by [ven_grp], xx_lawTemp.[comp_no],[acct_unit],[description],[company]
For reasons I won't get into I can't use SQL to do what I need to do.
this is how far I got with LINQ
Dim query = From l In law, c In comps _
Where l("ven_grp") = c("comp_parent") And l("company") = c("comp_struct1") _
Select l
which works ok, but I can't for the life of me figure out how to group on the fields I need to and then dump the query results into datatable. i need to follow the groupings that are in the SQL query above. I've looked at tons of examples on line and I just don't seem to get it or it does not work the way examples show. Both of my tables are defined as similar "Dim law = ds.tables(0).asenumerable()