Otis wrote:
Use IDataAccessAdapter in your code, which then will be db agnostic. You then create a simple factory for the DataAccessAdapter classes to produce one for the db you need.
I am already using a factory method per solution and IDataAccessAdapter is used all through the code.
I want to move the factory class to the application framework. It will contain code like this:
public class DataAccessAdapterFactory
{
public static IDataAccessAdapter GetDataAdapter( .... )
{
IDataAccessAdapter daToReturn;
...
if (someCondition)
daToReturn = new DataAccessAdapter( ... )
else
...
return daToReturn;
}
}
Now suppose i create two LLBLGen projects, module1 and module2. Using the standard templates two DataAccessAdapter classes will be generated, one
in namespace Module1.DBSpecific and one in namespace Module1.DBSpecific. Using the factorymethod above i can only create instances from one of the modules depending on wich assembly i reference.
If i want to be able to create the adapter for module1 and module2 i'll have to reference both assemblies. And every new LLBLGen project/module i create, i will have to reference.
This is not what i want. I want the framework to be more stable than the solutions/assemblies that reference it.
I compared the generated DataAccessAdapter code and noticed that the only difference is the namespace. The trouble is that the adapter needs persistence info in statements like
IFieldPersistenceInfo persistenceInfo = PersistenceInfoFactory.GetFieldPersistenceInfo(field.ContainingObjectName, field.Name);
and the PersistenceInfoFactory can be used because it is in the same namespace. Creating a generic adapter would require a method of supplying the persistence info at runtime.
I think this can be done, but it's a lot of work.