Friday, September 11, 2015

LINQ to LDAP: True polymorphic support

I've supported sub type mapping since version 1.0, but it was more of a way of reusing code for your directory objects than supporting polymorphism.

So you could map your classes like so:

But if you were to query for PersonInheritanceTest, every type that came back would be a PersonInheritanceTest object and then you'd have to do your own inspection on the object to load the real type.

LINQ to LDAP 4.0 will now let you map your sub types (remember to specify a unique set of object classes for your types!) and have the correct instances created. The only drawback is you have to map your objects up front now since I have to figure out the inheritance tree for mappings. Ad-hoc mapping will still work, but you may see different results depending on when the mappings get added via querying.