i'm really having a hard time deciding how to build my sql layer. i'm building a webservice that will communicate with both sql and No-SQL servers. So i came up with a bunch of ideas so that we can implemented testing, etc. etc.
Now i have bunch of files and a structure, i explain (Sorry i've i used names of patrons that i don't use... please correct me in that case): -IDatabaseStore.cs -SqlDatabaseStore.cs -NoSQLDatabaseStore.cs -and all my specific stores(like userStore.cs that implements the sql store for example).
And i wanted to do the following: Both SQL- and NoSQLDatabaseStore will implement the IDatabaseStore. These 2 classes will be abstract to provide the basic functionalities like the Repository pattern does. And all specific store will implement one of both abstract classes to not rebuild everything.
Now the problem: The No-SQL library that i use is MyCouch and is completly async, but for SQL i use L2SQL which isn't async.
Now my question: how is it preferred to set this up, in your opinion?
Like example 1, forcing that both use async methods, also if they aren't async(like L2SQL).
Make the interface like example 2, all dynamic an pass the generic type as Task in case that it needs to be Async. This way i don't obligate my interface nor abstract classes to be async (But void methods aren't async ever that case?).
Did i missed a way to make L2SQL async? Notice: I've seen a lot of posts already, but they don't seem to fit in this model.
Any other suggestions?
In case of performance i really would love tho have an Async L2SQL, because i will need to manage a lot of connections and this could really benifit the webservice. But for example a solution like: https://stackoverflow.com/a/252426/1364241 isn't awaitable, no?
Example 1:
public interface IDatabaseStore {
Task<T> GetByID(string id);
Task<List<T>> GetAll();
Task Delete(T model);
Task Update(T model);
Task Insert(T model);
}
Example 2:
public interface IDatabaseStore {
T GetByID(string id);
List<T> GetAll();
void Delete(T model);
void Update(T model);
void Insert(T model);
}