-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
|
||
namespace FreeSql | ||
{ | ||
|
||
public interface IRepositoryUnitOfWork : IUnitOfWork | ||
{ | ||
/// <summary> | ||
/// 在工作单元内创建联合主键的仓储类,工作单元下的仓储操作具有事务特点 | ||
/// </summary> | ||
/// <typeparam name="TEntity"></typeparam> | ||
/// <returns></returns> | ||
IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : class; | ||
} | ||
|
||
class RepositoryUnitOfWork : UnitOfWork, IRepositoryUnitOfWork | ||
{ | ||
|
||
public RepositoryUnitOfWork(IFreeSql fsql) : base(fsql) | ||
{ | ||
} | ||
|
||
public IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : class | ||
{ | ||
var repo = new DefaultRepository<TEntity, int>(_fsql); | ||
repo.UnitOfWork = this; | ||
return repo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters