Currently we are using Sql Server and Entity framework in our application. We have our own custom membership provider which is based on Sql Server. We are using EF as ORM.
We are in the process of updating our application to handle MongoDb as well. We are starting with making changes to Membership Provider.
As of now our BL directly creating instances of entity models and doing db operations. Which I think not a good design.
I want my BL should not get changed based on the DB. It should create an instance of repository object and forward the request(CRUD operation). Repository will take care of communicating with DAL. Please correct me if I am wrong.
I am thinking of creating an interface which will be implemented by repositories and repository getting used from BL. Interface will look like this.
interface IDataRepository
{
MembershipUser CreateUser(string firstName, stringLastName, string email, string phone);
}
1). Please advise me a better way of doing it.
2). If my application has different repositories, how the BL should decide which repository it should use. Would be using a Factory pattern good idea for this?
Thanks, Naresh
I think you are on the right track break out your application into tiers and then you Repository or DAL layer can be what ever you need (SQL, web service, whatever) then use a factory or a DI to get the data as you need it.
Here are DB post about doing it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.