Questions tagged [linq-group]

139 questions
1
vote
2 answers

Sorting Groups to display them by date of containing element (LINQ)

I'm not sure if this is possible. My class I have a list of looks like this: class Person { string Firstname string Lastname DateTime Timestamp } Now I would like to create groups by Firstname and Lastname. John Deer, 3:12 John Deer, 6:34 John…
sust86
  • 1,870
  • 2
  • 18
  • 25
1
vote
1 answer

Grouping Similar columns and concatenate other columns in LINQ

I have the following class public class InvoiceRO { public int ID{ get; set; } public string Address { get; set; } public string Reference1 { get; set; } public string DNNumber { get; set; } public string QuotationNumber {…
Akhil
  • 1,918
  • 5
  • 30
  • 74
1
vote
2 answers

LINQ group by sequence and count with sorting

I am searching a best performance method to group and count sequences with sorting using LINQ. I will be processing files even bigger than 500 MBs so performance is most important key in that task. List num2 = new List(); num2.Add(new…
maszynaz
  • 309
  • 4
  • 11
1
vote
2 answers

achieving a complex sort via Linq to Objects

I've been asked to apply conditional sorting to a data set and I'm trying to figure out how to achieve this via LINQ. In this particular domain, purchase orders can be marked as primary or secondary. The exact mechanism used to determine…
Mitch A
  • 2,050
  • 1
  • 21
  • 41
1
vote
1 answer

LINQ not trivial Group By

I have the following classes (omit syntax errors please) class Message { public Person Recipient ... } class Person { public List Groups ... } class Group { public GroupTypesEnum GroupType ... } I want to generate a count…
sports
  • 7,851
  • 14
  • 72
  • 129
1
vote
2 answers

Group by same value and contiguous date

var myDic = new SortedDictionary () { { new DateTime(0), 0 }, { new DateTime(1), 1 }, { new DateTime(2), 1 }, { new DateTime(3), 0 }, { new…
scanpat
  • 309
  • 1
  • 4
  • 8
1
vote
1 answer

group equal files in a directory

I'm writing a code to group equal files in a given directory using the hashCompute method. I have done most of the work but I can't seem to group my files. I want files with same hash value to be grouped together. Here's a sample of my code: public…
1
vote
1 answer

DataTable group the result in one row

I have a DataTable and want to group Name, LastName and Comment. The rest should be in the same row. In my Code firstly i make ID's values as header and then organize the Attribute values to each ID. What I want here is to group the the same Name,…
Uni Le
  • 783
  • 6
  • 17
  • 30
1
vote
2 answers

DataTable group the result

I want to group in Datatable by Name, LastName and the rest should be in same row. Can someone help me with it? My DataTable: Name LastName 1 3 2 kiki ha FF lola mi AA ka xe …
Uni Le
  • 783
  • 6
  • 17
  • 30
1
vote
1 answer

Group the result using linq

I have some problems and don't know what to do, can someone help me please? I have a table like that: ID Name Produkt Comment aa bb 1 Mike AA YY x 1 Mike AA YY x I want to group with linq…
Uni Le
  • 783
  • 6
  • 17
  • 30
1
vote
1 answer

Converting SQL to LINQ to Entity

I am trying to convert the following SQL, not written by myself, into a Linq to Entity query. select u.user_Id, u.forename, u.surname, u.client_code, u.user_name, u.password, u.email, u.gender, …
user1688784
  • 31
  • 1
  • 4
1
vote
0 answers

EntityCommandException on Linq with group by and count

I am facing EntityCommandException when I try to print out LINQ results. This is my code: var contacts = from c in db.mydata join r in db.contacts on c.user equals r.user group c by new { c.user, r.name } …
1
vote
1 answer

how to use group by in a linq query?

I have a list of products with productname, productprice & category. I want to write a linq query to group all the products according to category. I have tried the following: var p = from s in productlist group s by s.Category into g …
Badhon Jain
  • 938
  • 6
  • 20
  • 38
1
vote
3 answers

LINQ Dictionary Non-Distinct Values

I am struggeling a little with trying to write the LINQ query to do the following, public class MyClass { public int ID {get; set;} public int Name {get; set;} public IEnumerable SomeIEnumerable {get; set;} } I am trying to…
M Afifi
  • 4,645
  • 2
  • 28
  • 48
0
votes
2 answers

Sum, Order, Group, and Top/Take in Linq

I'm very new to LINQ, I've searched the boards but none of the other q/a's give a complete sample. I need to query with LINQ a strongly typed IList<> object and I must: Sum by a property Group by a property Order by the same property I did Sum…
SR8
  • 53
  • 5