madhatter22 / LinqToLdap

C# LINQ provider built on top of System.DirectoryServices.Protocols for querying and updating LDAP servers.
MIT License
45 stars 23 forks source link

On Skip() and Page on non typed search #2

Closed ssteiner closed 5 years ago

ssteiner commented 7 years ago

Hi

I have to return results in pages but the query needs to be non typed. if I do it typed, I can work with Skip() and Page() just fine and the results returned match my expectations. But, in order for Skip to work, I also need to add an order statement. And I'm having trouble figuring out how to write that Order statement in case of a non typed query.

Here's my query:

            IQueryable<IDirectoryAttributes> userQuery = context.Query(directoryOu).Where(filter);
            IQueryable<IDirectoryAttributes> ids2 = userQuery.Select("cn", "uid", "objectGUID", "sn", "givenName", "whenChanged", "userAccountControl", "sAMAccountName");
            ids2 = ids2.OrderBy(u => u.GetString("sn"));
            List<IDirectoryAttributes> results = ids2.InPagesOf(10).ToList();

This would be a non working attempt to order the results by sn .. I've also tried u=> u.DistinguishedName which doesn't appear to be working (gets me a "{"DistinguishedName was not found as a mapped property on LinqToLdap.Collections.DirectoryAttributes"}") either and working with u.Entry also doesn't appear to get me anywhere.

What's the proper order statement so the above would start working?

Thanks Stephan

madhatter22 commented 6 years ago

I will look into this. I may have missed support for dynamic OrderBy.

ssteiner commented 6 years ago

Any news on this? Thanks

madhatter22 commented 5 years ago

Sorry for the late response. I'm going to add OrderBy support for DirectoryAttributes. In the mean time you can use OrderBy("sn").