I understand we can very easily do this by a simple cycle, but I would like to persue this LINQ/Predicate?
LalitLalit
4 Solutions
In this article. The IEnumerable source has generally originated from a LINQ to DataSet expression or method query. The schema of the cloned DataTable is built from the columns of the first enumerated DataRow object in the source table and the name of the cloned table is the name of the source table with the word 'query' appended to it. Aug 03, 2011 0 down vote favorite I have three columns in a datatable: string, DateTime, and decimal. I want to group by the string and decimal column, and for the rows grouped I want to sum the decimal values. I know how to do the sum part, but how do you group two different columns in a datatable? Hi Sam; You are most likely getting the exception.
Try out this (LINQ technique format):
or in LINQ Issue format:
Ensemble
is required, because Columns can be of type DataColumnCollection which is usually aIEnumerable
, not reallyIEnumerablelt;DataColumngt;
. The additional parts should end up being obvious.Daniel HilgarthDaniel Hilgarth
Sem VanmeenenSem Vanmeenen
I'd suggest using such extension method:
And consequently:
You may furthermore carry out one even more extension method for
DataTable
course to decrease code:![Linq Linq](/uploads/1/2/5/6/125699811/160682399.png)
And use it as comes after:
DeilanDeilan
consumer3233312user3233312
Not really the response you're also looking for? Search other queries labeled c#.netlinqdatatable or inquire your personal issue.
I have Desk1 and Desk2 in the form of
IEnumerablelt;DataRowgt;
. Both the dining tables have got columnsColumn1
andLine2
.I would including to perform a remaining outer join on
Line1
and would including to get a count of the rows present inDesk2
and load the records into a DataTable.I attempted the following query
Since the 'gary the gadget guy' represents the assembled data the gary the gadget guy.count earnings 1 for rows which does not have entries in Table 2. I would like to return '0' for those rows.
Input :
Table 1
Desk 2
Present Output :
Expected Results :
I possess looked at LINQ - Still left Join, Group By, and Count but I could not use the same into my query.
Can you help me repair this problem ?
Group♦
Karthikeyan KKarthikeyan T
1 Solution
allow
it become therefore:Since I didn't join, I wear't possess to team. Each result line corresponds to a line in Table1.
Here's a GroupJoin alternative:
And right here's a Join and Team solution.
![Linq query to datatable Linq query to datatable](/uploads/1/2/5/6/125699811/328779650.png)
Amy NAmy M