I’m working with an existing EF data model that includes subclassed objects. That works fine when working with individual objects, but is quite slow when loading a large number of objects for analysis.
I started exploring Dapper as an alternative for populating POCO objects used for read-only analysis.
The trouble is, I can’t see any means to correctly handle an object hierarchy.
If I have
class MyBase
{
}
class MyDerived1 : MyBase
{
}
class MyDerived2 : MyBase
{
}
Dapper correctly populates a list of MyBase
var mine = conn.Query<MyBase>("SELECT * from MyTable");
The Multimap capability doesn’t seem to solve the problem (or am I missing something?).
Is there a way to solve this, short of making one round-trip to the database for each subclass?
Multimapping or a dynamic mapping should do the trick.
MM:
The dynamic mapping is also very cool and probably more flexible in your case (Thanks @Sam!)