var EmpRecList = (from ur in db.Users
join ug in db.UserGroups on ur.UserGroupID equals ug.UserGroupID
select new
{
lastName = ur.LastName,
userID = ur.UserID,
firstName = ur.FirstName,
userGroupName = ug.UserGroupNameLang1
}).Where(oh => oh.userGroupName.StartsWith(userCur.UserGroupName))
.OrderBy(x => x.lastName);
I have this code snippet. The problem here is, im getting 2 records with the same user ID. I would like to have a distinct record based on the User ID. Thanks. Tried using distinct method but no success.
You can use GroupBy and than get First record. It will get the first record which is in EmpRecList according to userid after ordering, but it will not ensure the result which you want to get.
Try this