我有一个View在LNameByFName中检索2个或更多相同的数据,显示相同的名称。无论索引如何,我如何只显示一个这些名称?在LINQ中过滤冗余数据
我可以使用FirstOrDefault()
,但我已经有.ToList()
public IEnumerable<EmployeeWithEmail> GetAllEmployeesWithEmail(int x)
{
using (var context = new SQL_TA_SCOREBOARDEntities1())
{
return (from ea in context.View_1
join vh in context.View_2 on (Int16)ea.EmpNo equals vh.EmpNo
join rl in context.View_3 on ea.RoleID equals rl.id into outer_join
from subjoin in outer_join where ea.GroupID == x
select new EmployeeWithEmail
{
EmpNum = ea.EmpNo ?? 0,
Role = subjoin.Role,
EmailAddress = vh.EmailAddress,
LNameByFname = vh.LNameByFName,
Active2 = ea.Active ?? false
}).ToList();
}
}
Aw。 'get'无法将lambda表达式转换为类型'System.Collections.Generic.IEqualityComparer',因为它不是'group new'和'rl'中的“group”的委托类型:在当前上下文中不存在。 –
user3483341
哎呀。那好吧。我没有办法测试这个,并想知道它是否会正确翻译。可能不会! –
没问题。感谢您的回应! – user3483341