I've been working on a code generater for my projects and, while all has worked well. But now, I've stumbled upon a detail that I'm not sure how to resolve. This is for my DAL layer, which is intended to allow implementations for diferente dataSources.
so I've got an interface:
public interface IUsersDALBase
{
//defined methods
}
a generic class that implements it:
public class UsersDALBase<T> : DBDataAccessBase where T : DBDataAccessBase, IUsersDALBase, new()
{
protected T _UsersInstance = default(T);
public string connectionString
{
get { return _UsersInstance.connectionString; }
set { _UsersInstance.connectionString = value; }
}
//constructors (...)
//interface method implementations, that call _UsersInstance methods (...)
}
For reference, DBDataAccessBase just holds the connection string and has disposing methods to standardize the *DALBAse classes. There is also an empty derived definition to extended (and there for not needing the "Base" suffix):
public partial class UsersDAL<T> : UsersDALBase<T> where T : DBDataAccessBase, IUsersDALBase, new()
{
//empty in generated file
}
this class is just a wrapper around UsersDALBase and is the one I want to extend in a new file. T type classes are mainly autogenerated also, but with DB specific implementations.
So finally, I want to extend UsersDAL in another file with custom methods that the generated code doesn't, and represented by a new interface
public interface IUsers2
{
UsersList GetAppRoleUsers(int NS_AppRole);
}
I'm trying something like:
public partial class UsersDAL<T> : UsersDALBase<T> where T : DBDataAccessBase, IUsers2, new()
{
//interface method implementation
//compile error: Partial declarations of 'DAL.UsersDAL<T>' have inconsistent
//constraints for type parameter 'T' -supose i can't have diferente interface
//implementations for T...
}
I basicly want UserDAL to have all the autogenerated methods (that implement IUsersDALBAse) and the methods that I've defined in the new interface IUsers2. Any Ideas on how I can get this???
Thanks!