fpoyavo
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();
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();
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?
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.
ASKER
Some of them. Not all.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.