Link to home
Start Free TrialLog in
Avatar of fpoyavo
fpoyavoFlag for United States of America

asked on

LINQ GroupBy

Hi Experts,

I need your help to add grouping by T.tid   in this code. Thank you in advance.


                    var mydata = db.data
                   
                    .Where(T => T.some.Any(F => F.my_id == another_id))
                   
                    .ToArray()
                 
                    .Select(T => new MyInfo
                    {
                        TId = T.tid,
                        PData = T.data
                       
                     
                    }).ToArray();
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi fpoyavo;

What is the data type of T.tid? Because if you create a grouping it will return a hierarchical data object. What is also the data type of MyInfo.Tid? Because it will need to store that object.

Can you show in a diagram what you want that grouping to look like or what you need it to look like.
Avatar of fpoyavo

ASKER

T.tid is int. MyInfo.Tid is int. MyInfo.PData is string.
So what are you trying to accomplish by grouping in the query?
Avatar of fpoyavo

ASKER

To eliminate duplicated data
Grouping will not get rid of duplicates. When you say duplicates does that mean that all columns having the same values or certain columns only.
Avatar of fpoyavo

ASKER

Some of them. Not all.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial