Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Medic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
Medic
Commits
3de96791
Commit
3de96791
authored
May 21, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement unit of work
parent
ea519b6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
UnitOfWork.cs
Infrastructure/UnitOfWork/UnitOfWork.cs
+32
-2
No files found.
Infrastructure/UnitOfWork/UnitOfWork.cs
View file @
3de96791
using
System
;
using
ApplicationCore.Entities
;
using
ApplicationCore.Interfaces
;
using
Infrastructure.Repository
;
using
Microsoft.EntityFrameworkCore
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -6,7 +10,33 @@ using System.Threading.Tasks;
...
@@ -6,7 +10,33 @@ using System.Threading.Tasks;
namespace
Infrastructure.UnitOfWork
namespace
Infrastructure.UnitOfWork
{
{
class
UnitOfWork
public
class
UnitOfWork
<
T
>
:
IUnitOfWork
<
T
>
where
T
:
EntityBase
{
{
private
readonly
DbContext
_context
;
private
IGenericRepository
<
T
>
_entity
;
public
UnitOfWork
(
DbContext
context
)
{
_context
=
context
;
_entity
=
new
GenericRepository
<
T
>(
context
);
}
public
IGenericRepository
<
T
>
Entity
{
get
{
return
_entity
??
(
_entity
=
new
GenericRepository
<
T
>(
_context
));
}
}
void
IUnitOfWork
<
T
>.
Save
()
{
_context
.
SaveChanges
();
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment