欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Lambda表达式去重

程序员文章站 2022-06-11 17:09:39
...
        string sql = [email protected]"SELECT g.GroupID, g.GroupName,ge.EmployeeId,e.employeename FROM dbo.tab_UserGroup g
                                LEFT JOIN dbo.tab_GroupEmployee ge ON g.GroupId = ge.GroupID
                                LEFT JOIN dbo.tabEmployee e ON ge.EmployeeId = e.employeeid
                                WHERE g.EmployeeId = '{user.data.employeeid}'";

        var result = db.SqlQueryable<GroupInfo>(sql).ToList();


        var items = result.Where((x, i) => result.FindIndex(z => z.GroupID == x.GroupID) == i).ToList();//Lambda表达式去重  
相关标签: 代替Distinct