优化数据仓储

This commit is contained in:
不做码农
2022-03-19 08:04:08 +08:00
parent 3e6d2fdce1
commit 1c3cdb99e0
29 changed files with 86 additions and 699 deletions

View File

@@ -1,44 +1,20 @@
using Infrastructure.Model;
using SqlSugar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZR.Model;
namespace ZR.Repository
{
public interface IBaseRepository<T> where T : class, new()
public interface IBaseRepository<T> : ISimpleClient<T> where T : class, new()
{
#region add
int Add(T t);
//int Insert(SqlSugarClient client, T t);
int Insert(List<T> t);
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
//int InsertIgnoreNullColumn(List<T> t);
//int InsertIgnoreNullColumn(List<T> t, params string[] columns);
//DbResult<bool> InsertTran(T t);
//DbResult<bool> InsertTran(List<T> t);
long InsertReturnBigIdentity(T t);
//T InsertReturnEntity(T t);
//T InsertReturnEntity(T t, string sqlWith = SqlWith.UpdLock);
//bool ExecuteCommand(string sql, object parameters);
//bool ExecuteCommand(string sql, params SugarParameter[] parameters);
//bool ExecuteCommand(string sql, List<SugarParameter> parameters);
IInsertable<T> Insertable(T t);
#endregion add
@@ -70,7 +46,6 @@ namespace ZR.Repository
#region delete
IDeleteable<T> Deleteable();
int Delete(Expression<Func<T, bool>> expression);
int Delete(object[] obj);
int Delete(object id);
int DeleteTable();
@@ -88,24 +63,12 @@ namespace ZR.Repository
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderByType);
bool Any(Expression<Func<T, bool>> expression);
ISugarQueryable<T> Queryable();
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
//ISugarQueryable<T, T1, T2> Queryable<T1, T2>() where T1 : class where T2 : new();
List<T> GetList(Expression<Func<T, bool>> expression);
//Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression);
//string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere);
//List<T> QueryableToList(string tableName);
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
@@ -113,23 +76,9 @@ namespace ZR.Repository
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
List<T> SqlQueryToList(string sql, object obj = null);
/// <summary>
/// 获得一条数据
/// </summary>
/// <param name="where">Expression<Func<T, bool>></param>
/// <returns></returns>
T GetFirst(Expression<Func<T, bool>> where);
T GetId(object pkValue);
/// <summary>
/// 获得一条数据
/// </summary>
/// <param name="parm">string</param>
/// <returns></returns>
//T GetFirst(string parm);
int Count(Expression<Func<T, bool>> where);
#endregion query
#region Procedure