Questions tagged [linq-group]

139 questions
0
votes
2 answers

Linq Group by id

var query = from c in context.Auto join r in context.Label on c.idAutoChar equals r.idAutoChar join g in context.Rent on c.idAuto equals g.idAuto where c.idAutoChar == r.idAutoChar && c.idAuto == g.idAuto …
0
votes
1 answer

.Net Linq Group by Join

I've the following code: Departement[] dept = { new Departement {Id = 'S', Name = "Sales" }, new Departement {Id = 'R', Name = "R&D" }, new Departement {Id = 'M', Name = "Marketing" }, new Departement {Id = 'L', Name = "Logistics"…
user3477008
  • 94
  • 1
  • 1
  • 9
0
votes
2 answers

Creating Groups out of two different lists

I guess this is an easy one but I have no clue how to do this. I have two lists of Persons List specificPersons List allPersons I would like to create groups out of the two complete lists like the following with…
sust86
  • 1,870
  • 2
  • 18
  • 25
0
votes
1 answer

how to perform groupby in linq on DataTable inside vb code?

How do I perform group in LINQ inside vb code (dot.net v4.0) with DataTable and sum on the group? In the sample below I need to add group by GroupName, ProductName and perform sum on QTY. The columns, order and where should remain as in sample, I…
user2455595
  • 67
  • 1
  • 2
  • 9
0
votes
1 answer

Allow null table in Group

I'm trying to write a LINQ query in C# expression to get an overview for a Purchase Order which includes a table TblPODetails with the list of items in the purchase order. I want to get every line item in this table and then add to it the total…
Joe_DM
  • 985
  • 1
  • 5
  • 12
0
votes
1 answer

Linq to SQL with group by

How do I write this query in linq VB.NET? select top 15 count(1), A.Latitude, A.Longitude from Bairro A inner join Empresa B on B.BairroID = A.BairroID where A.CidadeID = 4810 group by A.Latitude, A.Longitude order by COUNT(1) desc I reached this…
Fernando
  • 2,123
  • 4
  • 17
  • 21
0
votes
4 answers

Total salary for department wise group by concept using linq in asp.net

I am new to linq query in Asp .Net. I want total salary for department wise using group by concept. I want result using linq query so please help me friends. I have taken one table see below. Can you please give a solution for my query? I had tried…
user1858830
  • 1
  • 1
  • 2
0
votes
1 answer

LINQ filter on table to meet several criteria / DateDifference

I have a problem filtering a DataTable on different criteria. I know the first where-clause where row.Field("DateDifference") >= TimeSpan.Zero is why the third criterion isn't met. Is there any way to change my query to meet all…
abeldenibus
  • 128
  • 7
0
votes
2 answers

Select duplicates from multiple lists

I have an array of List, I'm using LINQ (thanks to this forum), to find duplicates, but after merging lists into one list, how can I retrieve a dictionary like this : KEY -> duplicate value | VALUE -> list index where duplicate was…
Mirko Arcese
  • 5,133
  • 2
  • 13
  • 11
0
votes
1 answer

Query to sum on grouped field

I've a list of tasks. Ie I've struct like struct Task { public DateTime Completed { get; set; } public string TaskKind { get; set; } public float Effort { get; set; } } And I've a IList. Now I want to group the tasks based on the…
Madhan Ganesh
  • 2,273
  • 2
  • 24
  • 19
0
votes
1 answer

LINQ Composite Key GroupJoin with keys unknown at compile time

I'm trying to get a GroupJoin to work with multiple unknown keys using LINQ. I've seen solutions with anonymous types, but the keys were always pre-defined. In my case, they're user-defined, so I wouldn't know that information at compile time. I…
Gustavo Azevedo
  • 113
  • 1
  • 7
0
votes
0 answers

Linq grouping with joins

I am constructing some XML using Linq to object and have managed to get what I want using code similar to the following example. I can't help feeling that it could be better though. What really bothers me is the "illustrations" node where I have…
David Hyde
  • 902
  • 9
  • 18
0
votes
1 answer

Group by array contents

I have a List> and I want to group by the contents of the byte array. Is there a simple way to do this with GroupBy and a lambda? Ideally, I want to do this without creating an intermediate data structure (like a string to…
soandos
  • 4,978
  • 13
  • 62
  • 96
0
votes
6 answers

Grouping in linq

I have a following list of documents: List list1 = new List() { new DocumentInfo { Name = "Customer1", DocCount = 5 }, new DocumentInfo { Name = "Customer1", DocCount = 10 }, new DocumentInfo { Name =…
mrd
  • 2,095
  • 6
  • 23
  • 48
0
votes
3 answers

Group List by properties and get number of times grouped

Lets say I have a class called Person: public class Person { public int Age { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } And a list of persons: Person { Age = 20, FirstName = "John",…
Dumpen
  • 1,622
  • 6
  • 22
  • 36