Duplicate Rows when Data Binding with LINQ to Entities

前端 未结 4 669
野性不改
野性不改 2020-12-05 19:38

I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView to the results of the following LINQ to entities query. In both cases the grids contain

4条回答
  •  被撕碎了的回忆
    2020-12-05 20:23

    And if you wrap the link query in a parenthesis and use the .Distinct() extension?

    public IEnumerable FindPersons(string searchTerm)
    {
        DirectoryEntities dents = new DirectoryEntities();
        return (from dp in dents.DirectoryPersonEntrySet
               where dp.LastName.StartsWith(searchTerm) || dp.Extension.StartsWith(searchTerm)
               orderby dp.LastName, dp.Extension
               select dp).Distinct();
    }
    

提交回复
热议问题