Although this is not an ideal solution, I decided to group the object after I had executed the query, but prior to serializing the data. I tried to apply a 'group by' clause, but I do not have any aggregates to apply as I was not attempting to find a max or sum of the child items, rather a straight group. My (unrefined) solution looks like so, using my original query, but placed into a custom entity class:
from parent in db.ParentTable
join child in db.ChildTable on new { Userid = parent.Id } equals new { Userid = child.Userid }
where
child.Col1 == Argument1 &&
child.Col2 == Argument2
select new ChildDataDomainModelClass {
Username = parent.Username,
child.Col1,
child.Col2,
child.Col3,
child.Coln
}
//I had grouped the object like this, where the object type returned on the grouping is of type IEnumerable<IGrouping<KeyValuePair<int, string>, ChildDataDomainModelClass>>:
List<ResultDataClass> returnData= new List<ResultDataClass>();
var groupedByUserName = dataResult.GroupBy(item => new KeyValuePair<int, string>(item.UserID, item.UserName), item => item);
foreach (var userData in groupedByUserName)
{
var newdata = new ResultDataClass(userData.Key.Key, userData.Key.Value, userData.Select(item => item.TrackData)); //TrackData is what I have named the Child Data that was returned
returnData.Add(newdata);
}
I do appreciate the input offered. If anyone has a more elegant solution to this problem where I do not have to loop over the objects prior to creating the custom class, let me know. Ideally, I would not have to create the 'ChildDataDomainModelClass' and through my query, I would select new 'ResultDataClass'. I hope this would help others that have encountered this problem. If I come up with a solution, I will update this post accordingly. I appreciate everyone's input. Thanks.