As part of an ORM microplatform I'm developing, I'm defining a generic class that implements exclusively tight coupling (1 record x 1 object).
public class Course : MicroEntity<Course>
{
public string fullname { get; set; }
public string shortname { get; set; }
public string summary { get; set; }
public string format { get; set; }
[...]
}
To define the behavior of this class, I have an Attribute that contains all the initialization characteristics:
[MicroEntity(
TableName = "mdl_course",
IdentifierColumnName = "ID",
IsReadOnly = true,
UseDistributedCaching = true)]
public class Course : MicroEntity<Course>
{
public string fullname { get; set; }
public string shortname { get; set; }
public string summary { get; set; }
public string format { get; set; }
[...]
}
Recently I've implemented a DatabaseAdapter engine to allow agnostic connection to different databases:
public abstract class BaseAdapter
{
internal abstract void CheckDatabaseEntities<T>() where T : MicroEntity<T>;
internal abstract void SetSqlStatements<T>() where T : MicroEntity<T>;
internal abstract void SetConnectionString<T>() where T : MicroEntity<T>;
internal abstract void RenderSchemaMicroEntityNames<T>() where T : MicroEntity<T>;
internal abstract BaseDynamicParameters Parameters<T>(object obj) where T : MicroEntity<T>;
internal abstract DbConnection Connection(string connectionString);
}
From there, I declare Adapters for different banks. I currently have adapters for Oracle and MySql.
Question
I'd like to be able to declare the adapter as an Attribute property:
[MicroEntity(
TableName = "mdl_course",
IdentifierColumnName = "ID",
IsReadOnly = true,
Adapter = new InternalAdapters.MySql.Adapter();
UseDistributedCaching = true)]
public class Course : MicroEntity<Course>
{
[...]
However, new()
is not allowed. Which model would best meet this type of behavior?