This project is read-only.

On paging, sorting, and filtering.

Oct 27, 2015 at 2:47 PM
I read a few of Alan's blog posts and the documentation about sorting returning "refused",

I've encountered the same refusal to sort, I'm using a few where clauses but no filters, and the resultset would be large but I am paging.

The old application used DirectoryServices and the same query works and is sorted so I'm hoping to get it working with Linq to LDAP as it is so much simpler to work with.

In this blog Alan mentions " I applied a filter and everything worked.", can anyone help me understand the difference between Where() and filters, and, what sort of filter I should use to help sorting work? Or is he simply saying you need to reduce the results before sort will work?

Example code:
    var config= new LdapConfiguration().MaxPageSizeIs(MaxPageSize);

                .AuthenticateAs(new NetworkCredential(LdapCredentials.Username, LdapCredentials.Password))

    var context = new DirectoryContext(config);

    var query = context.Query<LdapUser>();

     query = query.Where(x => x.EmployeeId != null);

 var emailOrPhone = PredicateBuilder.Create<LdapUser>()
                    .And(x => x.PhoneNumber != null && x.PhoneNumber != "000-000-0000")
                    .Or(x => x.Email != null);
                    query = query.Where(emailOrPhone);

query = query.Where(x => x.LastName.Contains(searchCriteria.LastName));

 query = query.OrderBy(x => x.CommonName);

var page = query.ToPage(MaxPageSize);