Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
Is it possible to implement Unit of Work with Generic Repository if my application is having multiple contexts and each context referring to different database. If So? Could you please provide an example.Any help will be highly appreciated.

public class GenericRepository<TEntity> where TEntity : class
{
    internal SchoolContext context;
    internal DbSet<TEntity> dbSet;

    public GenericRepository(SchoolContext context)
    {
        this.context = context;
        this.dbSet = context.Set<TEntity>();
    }
}
I am doing as above. My question is can I generalize the context to be able to use different contexts for the same GenericRepository Class.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900