Query-By-Example

Query by example allows you to do inline mapping and querying for faster development time. You can define any class as an example (anonymous or POCO) and then pass it in with the naming context. The first time the class is encountered, an Auto Class Map will be created for the object. Subsequent queries will not re-map the class. Your example property names must match the attribute names since the mapping is by convention. Specifying an ObjectCategory or ObjectClasses will include them in the query by default.

var example = new 
{ 
     DistinguishedName = "", 
     Cn = "", 
     ObjectGuid = default(Guid), 
     Members = default(string[]) 
};

var query = context.Query(example, "OU=Roles,DC=example,DC=com", objectClass: "Group")
     .Where(r => r.Cn == "Administrator");

Last edited Jun 6, 2012 at 2:33 AM by MadHatter22, version 5