Questions tagged [linq-group]
139 questions
4
votes
4 answers
Group a list into groups of 3 and select max of each group
I have a list of lists of dynamic which is currently being filtered through this:
var CPUdataIWant = from s in rawData
where s.stat.Contains("CPU")
select s;
//CPUDataIWant is a List
- >.
I have…

Chris Gregori
- 65
- 1
- 1
- 8
3
votes
1 answer
How to get and use source of grouping in LINQ?
I'd like to use parameter "o" (the source object) in the result of grouping, as so:
return (from o in objects
group o by MySpecialConverter(o) into g
select new Group
{
Key = g.Key,
Items =…

g_m
- 456
- 1
- 3
- 12
3
votes
2 answers
how to regard groupby in C# linq as a two dimensional list?
List data = new List(){
new History() {Symbol="a", Close = 1.0m, Date = new DateTime(2016, 2, 1) },
new History() {Symbol="a", Close = 1.2m, Date = new DateTime(2016, 2, 2) },
new History() {Symbol="a",…

user6703592
- 1,004
- 1
- 12
- 27
3
votes
3 answers
Linq syntax to find subtotal of grouped rows in a DataTable and update the DataTable
I have been scratching my head about this one... I have a table in memory, a DataTable structured like this:
Input:
ID | Invoice | Account | Payment | Subtotal
-----------------------------------------------------------------
0 | …

actinade
- 55
- 8
3
votes
1 answer
LINQ group items. A single item may be in several groups
I have an IEnumerable of items that I would like to group by associated categories. The items are grouped by the categories that are associated with them - which is a List - so a single item can potentially be a part of multiple categories.
var…

LinqHelpee
- 31
- 1
3
votes
1 answer
Dynamic linq query with nested groups
I'm trying to create nested group with dynamic query.
Following are my collection of data
var invoices = new List < Purchase > () {
new Purchase() {
Id = 1, Customer = "a", Date = DateTime.Parse("1/1/2009")
}, new Purchase() {
…

deadpool
- 31
- 2
3
votes
3 answers
linq groupby in strongly typed MVC View
How do i get an IGrouping result to map to the view?
I have this query:
var groupedManuals = manuals.GroupBy(c => c.Series);
return View(groupedManuals);
What is the proper mapping for the ViewPage…

jason
- 767
- 2
- 9
- 24
3
votes
3 answers
How does GroupBy in LINQ work?
I originally have a dictionary of > called rowsDictionary
Now for each key of that dictionary I group its list of values by some criteria as below:
Dictionary> providerGroups =…

ConfusedSleepyDeveloper
- 823
- 4
- 12
- 22
3
votes
1 answer
Create XML using LINQ
I have a table (datatable)which looks like this
Hotelid Room# Description visitor Name amount
1 2 of 5 sam 10
1 2 of 5 sam 5
1 2 of 5 sam…

rsj
- 61
- 1
- 2
- 8
3
votes
2 answers
c# Linq grouped by with composite key of int, list
I have a product object that has a certain location and allowable shipping methods for that product. What I'm trying to do is Group the products by location AND by the allowable ship methods.
For example the following example data would product two…

Ben Ziegler
- 895
- 1
- 7
- 18
3
votes
2 answers
Linq: Group by Time Interval
I've the following Datatable:
[Date];[Time];[ProcessID];[ID]
24.09.2012;08:18:00;4000;1
24.09.2012;08:18:00;4000;2
24.09.2012;08:19:00;4001;3
24.09.2012;08:23:00;4002;4
24.09.2012;08:32:00;4003;5
...
As result I would like to have a grouping by a…

user1434532
- 57
- 1
- 8
3
votes
2 answers
Group Results by Value after Split
I have searched but have not found my answer. Disclaimer: I am brand new to C# but I have a task at work to create the following program: Read from existing Log Files, Parse them by Tab, Limit the results to a specific status (Process E-mail), Group…

Cameron Balch
- 189
- 1
- 10
2
votes
4 answers
Linq join, group, count where count greater than value
I have the following linq expression that lets me join two tables, group them by a DSCID, and then get a count of the grouped values:
var qryGeoApppendCount =
from a in append
join g in geo
on…

jrubengb
- 363
- 1
- 7
- 14
2
votes
1 answer
Get Range Group Result from LINQ
I am having the following Data
List tradeList = new List();
tradeList.Add(new Trades() { securityId = "JKH.N0000", principalAmount = "100.00", tradeDate ="20160401", accountNumber = "JKB831230063VN00" });
tradeList.Add(new Trades() {…

hiFI
- 1,887
- 3
- 28
- 57
2
votes
1 answer
Group by Multiple Columns and Count
I have Table1 and Table2 in the form of IEnumerable. Both the tables have columns Column1 and Column2.
I would like to do a left outer join on Column1 and would like to get a count of the rows present in Table2 and load the records into a…

Karthikeyan K
- 23
- 1
- 1
- 3