This approach is that you do not want to switch to ORM generating code.
In your feature table, specify the fully qualified name of the feature type.
Then you can do something like:
private Dictionary<String, Type> _objectTypes = new Dictionary<String, Type>();
public ObjectFactory()
{
foreach (Type type in typeof(ObjectFactory).Assembly.GetTypes())
{
if (type.IsSubclassOf(typeof(BaseEntity)))
{
_objectTypes[type.Name.ToLower()] = type;
}
}
}
Now that you have all the preloaded maps, you can replace your code:
string objectName = dr["ClassType"].ToString().ToLower();
Type objectType;
if (_objectTypes.TryGetValue(objectName, out objectType))
{
return (BaseEntity)Activator.CreateInstance(objectType,reader);
}
, , factory.