diff --git a/Examples/repository_01/Controllers/SongController.cs b/Examples/repository_01/Controllers/SongController.cs index 51d9b9c8..f64a1a8c 100644 --- a/Examples/repository_01/Controllers/SongController.cs +++ b/Examples/repository_01/Controllers/SongController.cs @@ -39,8 +39,7 @@ namespace restful.Controllers DefaultRepository repos21, BaseRepository repos3, BaseRepository repos4, - IBasicRepository repos31, IBasicRepository repos41, - IReadOnlyRepository repos311, IReadOnlyRepository repos411, + IBaseRepository repos31, IBaseRepository repos41, SongRepository reposSong ) diff --git a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityTree.cs b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityTree.cs index abb28109..28be88c8 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityTree.cs +++ b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityTree.cs @@ -105,7 +105,7 @@ namespace FreeSql repo.Update(buf); } - T UpdateIsDelete(bool value, Func, List, T> func) + T UpdateIsDelete(bool value, Func, List, T> func) { var childs = GetAllChilds(); childs.Add(this as TEntity); diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index ca7c357b..28fdb213 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -110,13 +110,6 @@ 清空状态数据 - - - 根据 lambda 条件删除数据 - - - - 添加 @@ -218,29 +211,35 @@ + + + 分表规则,参数:旧表名;返回:新表名 https://github.com/2881099/FreeSql/wiki/Repository + + + 设置 DbContext 选项 - + 清空状态数据 - + 附加实体,可用于不查询就更新或删除 - + 附加实体,并且只附加主键值,可用于不更新属性值为null或默认值的字段 - + 保存实体的指定 ManyToMany/OneToMany 导航属性(完整对比) 场景:在关闭级联保存功能之后,手工使用本方法 diff --git a/FreeSql.DbContext/Repository/ContextSet/RepositoryDbContext.cs b/FreeSql.DbContext/Repository/ContextSet/RepositoryDbContext.cs index 978a952b..98abccd2 100644 --- a/FreeSql.DbContext/Repository/ContextSet/RepositoryDbContext.cs +++ b/FreeSql.DbContext/Repository/ContextSet/RepositoryDbContext.cs @@ -17,7 +17,6 @@ namespace FreeSql _repo = repo; } - static ConcurrentDictionary _dicGetRepositoryDbField = new ConcurrentDictionary(); static FieldInfo GetRepositoryDbField(Type type) => _dicGetRepositoryDbField.GetOrAdd(type, tp => typeof(BaseRepository<,>).MakeGenericType(tp, typeof(int)).GetField("_dbPriv", BindingFlags.Instance | BindingFlags.NonPublic)); public override IDbSet Set(Type entityType) diff --git a/FreeSql.DbContext/Repository/ContextSet/RepositoryDbSet.cs b/FreeSql.DbContext/Repository/ContextSet/RepositoryDbSet.cs index 195ae85a..2b33cf57 100644 --- a/FreeSql.DbContext/Repository/ContextSet/RepositoryDbSet.cs +++ b/FreeSql.DbContext/Repository/ContextSet/RepositoryDbSet.cs @@ -22,7 +22,7 @@ namespace FreeSql var filters = (_repo.DataFilter as DataFilter)._filters.Where(a => a.Value.IsEnabled == true); foreach (var filter in filters) select.Where(filter.Value.Expression); - return select.AsTable(_repo.AsTableSelectInternal); + return select.AsTable(_repo.AsTableSelectValueInternal); } internal ISelect OrmSelectInternal(object dywhere) => OrmSelect(dywhere); protected override IUpdate OrmUpdate(IEnumerable entitys) @@ -37,7 +37,7 @@ namespace FreeSql throw new Exception($"FreeSql.Repository Update 失败,因为设置了过滤器 {filter.Key}: {filter.Value.Expression},更新的数据不符合 {_db.Orm.GetEntityString(_entityType, entity)}"); update.Where(filter.Value.Expression); } - return update.AsTable(_repo.AsTableInternal); + return update.AsTable(_repo.AsTableValueInternal); } internal IUpdate OrmUpdateInternal(IEnumerable entitys) => OrmUpdate(entitys); protected override IDelete OrmDelete(object dywhere) @@ -45,7 +45,7 @@ namespace FreeSql var delete = base.OrmDelete(dywhere); var filters = (_repo.DataFilter as DataFilter)._filters.Where(a => a.Value.IsEnabled == true); foreach (var filter in filters) delete.Where(filter.Value.Expression); - return delete.AsTable(_repo.AsTableInternal); + return delete.AsTable(_repo.AsTableValueInternal); } internal IDelete OrmDeleteInternal(object dywhere) => OrmDelete(dywhere); protected override IInsert OrmInsert(TEntity entity) => OrmInsert(new[] { entity }); @@ -60,7 +60,7 @@ namespace FreeSql if (filter.Value.ExpressionDelegate?.Invoke(entity) == false) throw new Exception($"FreeSql.Repository Insert 失败,因为设置了过滤器 {filter.Key}: {filter.Value.Expression},插入的数据不符合 {_db.Orm.GetEntityString(_entityType, entity)}"); } - return insert.AsTable(_repo.AsTableInternal); + return insert.AsTable(_repo.AsTableValueInternal); } internal IInsert OrmInsertInternal(TEntity entity) => OrmInsert(entity); internal IInsert OrmInsertInternal(IEnumerable entitys) => OrmInsert(entitys); diff --git a/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs b/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs index 5fcebda7..e5479d93 100644 --- a/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs +++ b/FreeSql.DbContext/Repository/ContextSet/RepositoryUnitOfWork.cs @@ -13,7 +13,7 @@ namespace FreeSql /// /// 数据过滤 + 验证 /// - DefaultRepository GetRepository(Expression> filter = null) where TEntity : class; + IBaseRepository GetRepository(Expression> filter = null) where TEntity : class; /// /// 在工作单元内创建联合主键的仓储类,工作单元下的仓储操作具有事务特点 @@ -21,7 +21,7 @@ namespace FreeSql /// /// 数据过滤 + 验证 /// - BaseRepository GetRepository(Expression> filter = null) where TEntity : class; + IBaseRepository GetRepository(Expression> filter = null) where TEntity : class; /// /// 在工作单元内创建仓库类,工作单元下的仓储操作具有事务特点 @@ -30,7 +30,7 @@ namespace FreeSql /// 数据过滤 + 验证 /// 分表规则,参数:旧表名;返回:新表名 https://github.com/2881099/FreeSql/wiki/Repository /// - GuidRepository GetGuidRepository(Expression> filter = null, Func asTable = null) where TEntity : class; + IBaseRepository GetGuidRepository(Expression> filter = null, Func asTable = null) where TEntity : class; } class RepositoryUnitOfWork : UnitOfWork, IRepositoryUnitOfWork @@ -40,21 +40,21 @@ namespace FreeSql { } - public GuidRepository GetGuidRepository(Expression> filter = null, Func asTable = null) where TEntity : class + public IBaseRepository GetGuidRepository(Expression> filter = null, Func asTable = null) where TEntity : class { var repo = new GuidRepository(_fsql, filter, asTable); repo.UnitOfWork = this; return repo; } - public DefaultRepository GetRepository(Expression> filter = null) where TEntity : class + public IBaseRepository GetRepository(Expression> filter = null) where TEntity : class { var repo = new DefaultRepository(_fsql, filter); repo.UnitOfWork = this; return repo; } - public BaseRepository GetRepository(Expression> filter = null) where TEntity : class + public IBaseRepository GetRepository(Expression> filter = null) where TEntity : class { var repo = new DefaultRepository(_fsql, filter); repo.UnitOfWork = this; diff --git a/FreeSql.DbContext/Repository/Extensions/DependencyInjection.cs b/FreeSql.DbContext/Repository/Extensions/DependencyInjection.cs index 019684f1..e0ae86eb 100644 --- a/FreeSql.DbContext/Repository/Extensions/DependencyInjection.cs +++ b/FreeSql.DbContext/Repository/Extensions/DependencyInjection.cs @@ -1,29 +1,36 @@ #if netcoreapp -using System; -using System.Reflection; -using System.Linq; using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Reflection; namespace FreeSql { public static class FreeSqlRepositoryDependencyInjection { + /// + /// 批量注入 Repository,可以参考代码自行调整 + /// + /// + /// + /// + /// public static IServiceCollection AddFreeRepository(this IServiceCollection services, Action globalDataFilter = null, params Assembly[] assemblies) { + if (globalDataFilter != null) + { + DataFilterUtil._globalDataFilter = globalDataFilter; + //如果看到了这里的代码,想自己调整,但因为 _globalDataFilter 是内部属性,无法修改? + //请考虑改用 fsql.GlobalFilter.Apply + } - DataFilterUtil._globalDataFilter = globalDataFilter; - - services.AddScoped(typeof(IReadOnlyRepository<>), typeof(GuidRepository<>)); - services.AddScoped(typeof(IBasicRepository<>), typeof(GuidRepository<>)); + services.AddScoped(typeof(IBaseRepository<>), typeof(GuidRepository<>)); services.AddScoped(typeof(BaseRepository<>), typeof(GuidRepository<>)); - services.AddScoped(typeof(GuidRepository<>)); - services.AddScoped(typeof(IReadOnlyRepository<,>), typeof(DefaultRepository<,>)); - services.AddScoped(typeof(IBasicRepository<,>), typeof(DefaultRepository<,>)); + services.AddScoped(typeof(IBaseRepository<,>), typeof(DefaultRepository<,>)); services.AddScoped(typeof(BaseRepository<,>), typeof(DefaultRepository<,>)); - services.AddScoped(typeof(DefaultRepository<,>)); if (assemblies?.Any() == true) foreach (var asse in assemblies) diff --git a/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs b/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs index 9570ebdb..af4aaaaa 100644 --- a/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs +++ b/FreeSql.DbContext/Repository/Extensions/FreeSqlRepositoryExtensions.cs @@ -1,7 +1,7 @@ using FreeSql; using System; -using System.Linq.Expressions; using System.Linq; +using System.Linq.Expressions; public static class FreeSqlRepositoryExtensions { @@ -14,7 +14,7 @@ public static class FreeSqlRepositoryExtensions /// /// 数据过滤 + 验证 /// - public static DefaultRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class + public static IBaseRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class { return new DefaultRepository(that, filter); } @@ -26,7 +26,7 @@ public static class FreeSqlRepositoryExtensions /// /// 数据过滤 + 验证 /// - public static BaseRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class + public static IBaseRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class { return new DefaultRepository(that, filter); } @@ -39,26 +39,11 @@ public static class FreeSqlRepositoryExtensions /// 数据过滤 + 验证 /// 分表规则,参数:旧表名;返回:新表名 https://github.com/2881099/FreeSql/wiki/Repository /// - public static GuidRepository GetGuidRepository(this IFreeSql that, Expression> filter = null, Func asTable = null) where TEntity : class + public static IBaseRepository GetGuidRepository(this IFreeSql that, Expression> filter = null, Func asTable = null) where TEntity : class { return new GuidRepository(that, filter, asTable); } - ///// - ///// 合并两个仓储的设置(过滤+分表),以便查询 - ///// - ///// - ///// - ///// - ///// - ///// - //public static ISelect FromRepository(this ISelect that, BaseRepository repos) where TEntity : class where T2 : class - //{ - // var filters = (repos.DataFilter as DataFilter)._filters.Where(a => a.Value.IsEnabled == true); - // foreach (var filter in filters) that.Where(filter.Value.Expression); - // return that.AsTable(repos.AsTableSelectInternal); - //} - /// /// 创建基于仓储功能的工作单元,务必使用 using 包含使用 /// diff --git a/FreeSql.DbContext/Repository/Repository/BaseRepository.cs b/FreeSql.DbContext/Repository/Repository/BaseRepository.cs index df25b35d..cc8ec1bf 100644 --- a/FreeSql.DbContext/Repository/Repository/BaseRepository.cs +++ b/FreeSql.DbContext/Repository/Repository/BaseRepository.cs @@ -18,19 +18,8 @@ namespace FreeSql internal RepositoryDbSet _dbset => _dbsetPriv ?? (_dbsetPriv = _db.Set() as RepositoryDbSet); public IDataFilter DataFilter { get; } = new DataFilter(); - Func _asTableVal; - protected Func AsTable - { - get => _asTableVal; - set - { - _asTableVal = value; - AsTableSelect = value == null ? null : new Func((a, b) => a == EntityType ? value(b) : null); - } - } - internal Func AsTableInternal => AsTable; - protected Func AsTableSelect { get; private set; } - internal Func AsTableSelectInternal => AsTableSelect; + internal Func AsTableValueInternal { get; private set; } + internal Func AsTableSelectValueInternal { get; private set; } protected void ApplyDataFilter(string name, Expression> exp) => DataFilter.Apply(name, exp); @@ -39,7 +28,7 @@ namespace FreeSql Orm = fsql; DataFilterUtil.SetRepositoryDataFilter(this, null); DataFilter.Apply("", filter); - AsTable = asTable; + AsTable(asTable); } ~BaseRepository() => this.Dispose(); @@ -60,6 +49,11 @@ namespace FreeSql } public Type EntityType => _dbsetPriv?.EntityType ?? typeof(TEntity); public void AsType(Type entityType) => _dbset.AsType(entityType); + public void AsTable(Func rule) + { + AsTableValueInternal = rule; + AsTableSelectValueInternal = rule == null ? null : new Func((a, b) => a == EntityType ? rule(b) : null); + } public DbContextOptions DbContextOptions { get => _db.Options; set => _db.Options = value; } public IFreeSql Orm { get; private set; } @@ -125,7 +119,7 @@ namespace FreeSql public void Attach(TEntity data) => _db.Attach(data); public void Attach(IEnumerable data) => _db.AttachRange(data); - public IBasicRepository AttachOnlyPrimary(TEntity data) + public IBaseRepository AttachOnlyPrimary(TEntity data) { _db.AttachOnlyPrimary(data); return this; @@ -149,10 +143,7 @@ namespace FreeSql public abstract partial class BaseRepository : BaseRepository, IBaseRepository where TEntity : class { - - public BaseRepository(IFreeSql fsql, Expression> filter, Func asTable = null) : base(fsql, filter, asTable) - { - } + public BaseRepository(IFreeSql fsql, Expression> filter, Func asTable = null) : base(fsql, filter, asTable) { } TEntity CheckTKeyAndReturnIdEntity(TKey id) { @@ -167,9 +158,7 @@ namespace FreeSql } public int Delete(TKey id) => Delete(CheckTKeyAndReturnIdEntity(id)); - public TEntity Find(TKey id) => _dbset.OrmSelectInternal(CheckTKeyAndReturnIdEntity(id)).ToOne(); - public TEntity Get(TKey id) => Find(id); } } diff --git a/FreeSql.DbContext/Repository/Repository/BaseRepositoryAsync.cs b/FreeSql.DbContext/Repository/Repository/BaseRepositoryAsync.cs index d29433eb..c3e5dd42 100644 --- a/FreeSql.DbContext/Repository/Repository/BaseRepositoryAsync.cs +++ b/FreeSql.DbContext/Repository/Repository/BaseRepositoryAsync.cs @@ -73,11 +73,8 @@ namespace FreeSql partial class BaseRepository { - public Task DeleteAsync(TKey id) => DeleteAsync(CheckTKeyAndReturnIdEntity(id)); - public Task FindAsync(TKey id) => _dbset.OrmSelectInternal(CheckTKeyAndReturnIdEntity(id)).ToOneAsync(); - public Task GetAsync(TKey id) => FindAsync(id); } } diff --git a/FreeSql.DbContext/Repository/Repository/DefaultRepository.cs b/FreeSql.DbContext/Repository/Repository/DefaultRepository.cs index a1f69e07..6f36a3dc 100644 --- a/FreeSql.DbContext/Repository/Repository/DefaultRepository.cs +++ b/FreeSql.DbContext/Repository/Repository/DefaultRepository.cs @@ -3,18 +3,15 @@ using System.Linq.Expressions; namespace FreeSql { - public class DefaultRepository : - BaseRepository - where TEntity : class + public class DefaultRepository : BaseRepository where TEntity : class { + public DefaultRepository(IFreeSql fsql) : base(fsql, null, null) { } + public DefaultRepository(IFreeSql fsql, Expression> filter) : base(fsql, filter, null) { } + } - public DefaultRepository(IFreeSql fsql) : base(fsql, null, null) - { - - } - - public DefaultRepository(IFreeSql fsql, Expression> filter) : base(fsql, filter, null) - { - } + public class GuidRepository : BaseRepository where TEntity : class + { + public GuidRepository(IFreeSql fsql) : this(fsql, null, null) { } + public GuidRepository(IFreeSql fsql, Expression> filter, Func asTable) : base(fsql, filter, asTable) { } } } diff --git a/FreeSql.DbContext/Repository/Repository/GuidRepository.cs b/FreeSql.DbContext/Repository/Repository/GuidRepository.cs deleted file mode 100644 index 1025f961..00000000 --- a/FreeSql.DbContext/Repository/Repository/GuidRepository.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Linq.Expressions; - -namespace FreeSql -{ - public class GuidRepository : - BaseRepository - where TEntity : class - { - - public GuidRepository(IFreeSql fsql) : this(fsql, null, null) - { - - } - public GuidRepository(IFreeSql fsql, Expression> filter, Func asTable) : base(fsql, filter, asTable) - { - } - } -} diff --git a/FreeSql.DbContext/Repository/Repository/IBaseRepository.cs b/FreeSql.DbContext/Repository/Repository/IBaseRepository.cs index 5ea1f28b..e172073f 100644 --- a/FreeSql.DbContext/Repository/Repository/IBaseRepository.cs +++ b/FreeSql.DbContext/Repository/Repository/IBaseRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; @@ -17,6 +18,11 @@ namespace FreeSql /// /// void AsType(Type entityType); + /// + /// 分表规则,参数:旧表名;返回:新表名 https://github.com/2881099/FreeSql/wiki/Repository + /// + /// + void AsTable(Func rule); /// /// 设置 DbContext 选项 @@ -24,19 +30,83 @@ namespace FreeSql DbContextOptions DbContextOptions { get; set; } } - public interface IBaseRepository : IReadOnlyRepository, IBasicRepository + public interface IBaseRepository : IBaseRepository where TEntity : class { + IDataFilter DataFilter { get; } + ISelect Select { get; } + + ISelect Where(Expression> exp); + ISelect WhereIf(bool condition, Expression> exp); + + TEntity Insert(TEntity entity); + List Insert(IEnumerable entitys); + + /// + /// 清空状态数据 + /// + void FlushState(); + /// + /// 附加实体,可用于不查询就更新或删除 + /// + /// + void Attach(TEntity entity); + void Attach(IEnumerable entity); + /// + /// 附加实体,并且只附加主键值,可用于不更新属性值为null或默认值的字段 + /// + /// + IBaseRepository AttachOnlyPrimary(TEntity data); + + int Update(TEntity entity); + int Update(IEnumerable entitys); + + TEntity InsertOrUpdate(TEntity entity); + /// + /// 保存实体的指定 ManyToMany/OneToMany 导航属性(完整对比) + /// 场景:在关闭级联保存功能之后,手工使用本方法 + /// 例子:保存商品的 OneToMany 集合属性,SaveMany(goods, "Skus") + /// 当 goods.Skus 为空(非null)时,会删除表中已存在的所有数据 + /// 当 goods.Skus 不为空(非null)时,添加/更新后,删除表中不存在 Skus 集合属性的所有记录 + /// + /// 实体对象 + /// 属性名 + void SaveMany(TEntity entity, string propertyName); + + IUpdate UpdateDiy { get; } + + int Delete(TEntity entity); + int Delete(IEnumerable entitys); int Delete(Expression> predicate); #if net40 #else + Task InsertAsync(TEntity entity); + Task> InsertAsync(IEnumerable entitys); + + Task UpdateAsync(TEntity entity); + Task UpdateAsync(IEnumerable entitys); + Task InsertOrUpdateAsync(TEntity entity); + Task SaveManyAsync(TEntity entity, string propertyName); + + Task DeleteAsync(TEntity entity); + Task DeleteAsync(IEnumerable entitys); Task DeleteAsync(Expression> predicate); #endif } - public interface IBaseRepository : IBaseRepository, IReadOnlyRepository, IBasicRepository + public interface IBaseRepository : IBaseRepository where TEntity : class { + TEntity Get(TKey id); + TEntity Find(TKey id); + int Delete(TKey id); + +#if net40 +#else + Task GetAsync(TKey id); + Task FindAsync(TKey id); + Task DeleteAsync(TKey id); +#endif } } \ No newline at end of file diff --git a/FreeSql.DbContext/Repository/Repository/IBasicRepository.cs b/FreeSql.DbContext/Repository/Repository/IBasicRepository.cs deleted file mode 100644 index b0b4f804..00000000 --- a/FreeSql.DbContext/Repository/Repository/IBasicRepository.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace FreeSql -{ - public interface IBasicRepository : IReadOnlyRepository - where TEntity : class - { - TEntity Insert(TEntity entity); - List Insert(IEnumerable entitys); - - /// - /// 清空状态数据 - /// - void FlushState(); - /// - /// 附加实体,可用于不查询就更新或删除 - /// - /// - void Attach(TEntity entity); - void Attach(IEnumerable entity); - /// - /// 附加实体,并且只附加主键值,可用于不更新属性值为null或默认值的字段 - /// - /// - IBasicRepository AttachOnlyPrimary(TEntity data); - - int Update(TEntity entity); - int Update(IEnumerable entitys); - - TEntity InsertOrUpdate(TEntity entity); - /// - /// 保存实体的指定 ManyToMany/OneToMany 导航属性(完整对比) - /// 场景:在关闭级联保存功能之后,手工使用本方法 - /// 例子:保存商品的 OneToMany 集合属性,SaveMany(goods, "Skus") - /// 当 goods.Skus 为空(非null)时,会删除表中已存在的所有数据 - /// 当 goods.Skus 不为空(非null)时,添加/更新后,删除表中不存在 Skus 集合属性的所有记录 - /// - /// 实体对象 - /// 属性名 - void SaveMany(TEntity entity, string propertyName); - - IUpdate UpdateDiy { get; } - - int Delete(TEntity entity); - int Delete(IEnumerable entitys); - -#if net40 -#else - Task InsertAsync(TEntity entity); - Task> InsertAsync(IEnumerable entitys); - - Task UpdateAsync(TEntity entity); - Task UpdateAsync(IEnumerable entitys); - Task InsertOrUpdateAsync(TEntity entity); - Task SaveManyAsync(TEntity entity, string propertyName); - - Task DeleteAsync(TEntity entity); - Task DeleteAsync(IEnumerable entitys); -#endif - } - - public interface IBasicRepository : IBasicRepository, IReadOnlyRepository - where TEntity : class - { - int Delete(TKey id); - -#if net40 -#else - Task DeleteAsync(TKey id); -#endif - } -} - diff --git a/FreeSql.DbContext/Repository/Repository/IReadOnlyRepository.cs b/FreeSql.DbContext/Repository/Repository/IReadOnlyRepository.cs deleted file mode 100644 index bd96458f..00000000 --- a/FreeSql.DbContext/Repository/Repository/IReadOnlyRepository.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Linq.Expressions; -using System.Threading.Tasks; - -namespace FreeSql -{ - public interface IReadOnlyRepository : IBaseRepository - where TEntity : class - { - - IDataFilter DataFilter { get; } - - ISelect Select { get; } - - ISelect Where(Expression> exp); - ISelect WhereIf(bool condition, Expression> exp); - } - - public interface IReadOnlyRepository : IReadOnlyRepository - where TEntity : class - { - TEntity Get(TKey id); - TEntity Find(TKey id); - -#if net40 -#else - Task GetAsync(TKey id); - Task FindAsync(TKey id); -#endif - } -}