Cheers!I have some doubts about using Unit of Work with Repository. Specially a role of child context from Entity Framework. I have searched a lot of information about this theme, but all that I found just different types of using patterns, I'm confused and I can't understand main think.
1.Where I should realize disposing and saving? -Is it correctly realize Disposable in Inheritance class of DbContext? After that realize in Repository and Unit of Work or just in Uni fo Work?
-Where put method Save in Unit of Work or Repository?
My repository will be Generic Is my code is correct in architect style and other details?Please tell if my thinks are wrong.
interface IRepository : IDisposable
{
void Create();
void Delete();
void Update();
void Get();
T getSomeByExpression()
...Some another costum operations
...should I remember about Save here?
}
class Repository : IRepository
{
SomeContext context = new SomeContext();
...Using using(context = new SomeContext()){} in functions??
...
....Disposing?
}
interface IUnitOfWork : IDisposable
{
...Which methods I should realize?
Commit()
Save()
...Need some another methods like rollback, Attach() Add() or Dispose or something else?
}
class UnitOfWork
{
...Collection of Repository
}
Use after Unit of Work on Logic level? Please help me to understand this theme.
I want know, how correctly use Unit Of Work and Repository patterns together, especially include DBContext.Also I want know where use some operations like Dispose. Which operations should be in UnitOfWork commonly, Save etc. How disposing context in repository?