This project is read-only.

Using non generic Query method and limiting the attributes returned

Aug 6, 2015 at 9:10 AM

I'm looking at linqtoldap to replace an existing class lib that allows typed and no typed object searches. Typed is no problem.. I create my data object and use one of the Query<T> methods.

The non generic Query method returns a IQueryable<IDirectoryAttributes> and if used, returns all non null attributes for the given objects found. Is there a way to limit the attributes returned? There's no point in returning 100 attributes if all i care about are 5.

Aug 7, 2015 at 4:19 PM
I think I can answer this myself.
The query is only sent when you get a list or an item back.. so put a Select after Context.Query(), and only extract properties you're interested in as an anonymous type.

So you could use the generic Get method to extract the various attributes as follows
IQueryable<IDirectoryAttributes> userQuery = context.Query(directoryOu).Where(filter);
                List<DirectoryAttribute[]> ids = userQuery.Select(x => new DirectoryAttribute[]