Using the below linq statement I show a list of results which I join two tables called AssetTransferItems and Memberships. Memberships table contains a list of users where each user is stored as a GUID and contains their username.
I now want to add another column called UserReceived and like the UserAdded show the Username instead of GUID. UserReceived = txboxItems.UserReceived currently displays the GUID and I am trying to get the username.
I am not sure how I can modify the Linq statement to grab the username from the membership table for UserReceived. I added a 2nd join:
join userReceived in Memberships on txboxItems.UserReceived equals userReceived.UserId
But this did not display the results.
var query = (from txboxItems in AssetTransferItems
join user in Memberships on txboxItems.UserAdded equals user.UserId
join userReceived in Memberships on txboxItems.UserReceived equals userReceived.UserId
where txboxItems.TransferBoxID == BoxId && txboxItems.Deleted == false
orderby txboxItems.TicketID descending
select new
{
Description = txboxItems.Description.ToString(),
DateAdded = (DateTime?) txboxItems.DateAdded.Value,
UserAdded = user.Username,
DateReceived = (DateTime?) txboxItems.DateReceived.Value,
UserReceived = userReceived.Username,
});
EDIT: I updated the linq statement to reflect what I have now. It shows the userReceived.Username but all other results where UserReceived is null are not shown.
Thank you