LINQ Groub By and Return Alias ID and GroupName as Concat Data?

Difficult title indeed. I had the data returning great until including the Group By.  I need to combine two columns data like so:

         ID = g.Key,
         Group = categoryRef.Name + "/" + categorySubRef.Name

ID = 1, Group = Auto/Loan
ID = 2, Group = Auto/Repair
ID = 3, Group = Boat/Fuel


var groups = 
(from c in context.CategoryAsgns
 join r in context.CategoryRefs on c.CategoryID equals r.CategoryID
 join r2 in context.CategorySubRefs on c.CategorySubID equals r2.CategorySubID
 let j = new { categoryAsgn = c, categoryRef = r, categorySubRef = r2 }
 orderby j.categoryRef.Name ascending
 group j by j.categoryRef.Name into g
 select new { ID = g.Key, 
Group = categoryRef.Name +"/"+ categorySubRef.Name) }).ToList();

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
At the point of the group by, you can only access elements of "g", and not "categoryRef".  What does g.Value give you?  It should be anonymous type from the let statement.  

My guess is g.Value.categoryRef.Name + "/" + g.Value.categorySubRef.Name

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WorknHardrAuthor Commented:
Your guess is close, I'm using this one now;

select new {
CategoryAsgnID = g.FirstOrDefault().categoryAsgn.CategoryAsgnID,
GroupName = g.FirstOrDefault().categoryRef.Name
 + "/" +
WorknHardrAuthor Commented:
Thx for sending down the right path
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.