Files
shgx_tz_mes_backend_sync/ZR.Repository/IBaseRepository.cs

95 lines
3.3 KiB
C#
Raw Normal View History

2022-03-19 08:04:08 +08:00
using SqlSugar;
2021-09-27 08:06:09 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
2021-09-27 16:07:55 +08:00
using ZR.Model;
2021-09-27 08:06:09 +08:00
namespace ZR.Repository
{
2022-03-19 08:04:08 +08:00
public interface IBaseRepository<T> : ISimpleClient<T> where T : class, new()
2021-09-27 08:06:09 +08:00
{
#region add
2023-02-17 10:54:18 +08:00
int Add(T t, bool ignoreNull = true);
2021-09-27 08:06:09 +08:00
int Insert(List<T> t);
2021-11-27 09:43:04 +08:00
int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
IInsertable<T> Insertable(T t);
2021-09-27 08:06:09 +08:00
#endregion add
#region update
2022-01-18 21:52:23 +08:00
IUpdateable<T> Updateable(T entity);
2021-12-14 21:51:19 +08:00
int Update(T entity, bool ignoreNullColumns = false);
2021-09-27 08:06:09 +08:00
/// <summary>
/// 只更新表达式的值
/// </summary>
/// <param name="entity"></param>
/// <param name="expression"></param>
/// <returns></returns>
2021-12-14 21:51:19 +08:00
int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
2021-09-27 08:06:09 +08:00
2021-12-14 21:51:19 +08:00
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
2021-09-27 08:06:09 +08:00
2021-12-14 21:51:19 +08:00
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
2021-09-27 08:06:09 +08:00
2021-12-14 21:51:19 +08:00
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
2021-09-27 08:06:09 +08:00
#endregion update
2022-05-07 22:16:59 +08:00
IStorageable<T> Storageable(T t);
IStorageable<T> Storageable(List<T> t);
2021-11-20 18:24:41 +08:00
DbResult<bool> UseTran(Action action);
2021-09-27 08:06:09 +08:00
2021-11-20 18:24:41 +08:00
DbResult<bool> UseTran(SqlSugarClient client, Action action);
2021-09-27 08:06:09 +08:00
2021-11-20 18:24:41 +08:00
bool UseTran2(Action action);
2021-09-27 08:06:09 +08:00
#region delete
2022-02-10 22:01:59 +08:00
IDeleteable<T> Deleteable();
2021-11-20 18:24:41 +08:00
int Delete(object[] obj);
2021-09-27 16:07:55 +08:00
int Delete(object id);
2021-12-14 21:51:19 +08:00
int DeleteTable();
2022-09-21 21:43:05 +08:00
bool Truncate();
2021-09-27 08:06:09 +08:00
#endregion delete
#region query
2021-09-27 16:07:55 +08:00
/// <summary>
/// 根据条件查询分页数据
/// </summary>
/// <param name="where"></param>
/// <param name="parm"></param>
/// <returns></returns>
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
2022-01-05 07:17:44 +08:00
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderByType);
2022-03-19 08:04:08 +08:00
2021-09-27 16:07:55 +08:00
bool Any(Expression<Func<T, bool>> expression);
2021-09-27 08:06:09 +08:00
ISugarQueryable<T> Queryable();
2021-09-27 16:07:55 +08:00
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Expression<Func<T, object>> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
2021-09-27 08:06:09 +08:00
2021-11-27 09:43:04 +08:00
List<T> SqlQueryToList(string sql, object obj = null);
2021-09-27 08:06:09 +08:00
2022-03-19 08:04:08 +08:00
T GetId(object pkValue);
2021-10-17 17:34:57 +08:00
2021-09-27 08:06:09 +08:00
#endregion query
#region Procedure
2021-11-20 18:24:41 +08:00
DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
2021-09-27 08:06:09 +08:00
2021-11-20 18:24:41 +08:00
(DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
2021-09-27 08:06:09 +08:00
#endregion Procedure
}
}