using Infrastructure.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using ZR.Model;
namespace ZR.Service
{
///
/// 基础服务定义
///
///
public interface IBaseService where T : class, new()
{
#region add
int Add(T t);
//int Insert(SqlSugarClient client, T t);
//long InsertBigIdentity(T t);
IInsertable Insertable(T t);
int Insert(List t);
int Insert(T parm, Expression> iClumns = null, bool ignoreNull = true);
//int InsertIgnoreNullColumn(List t);
//int InsertIgnoreNullColumn(List t, params string[] columns);
//DbResult InsertTran(T t);
//DbResult InsertTran(List 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 parameters);
#endregion add
#region update
bool Update(T entity, bool ignoreNullColumns = false);
///
/// 只更新表达式的值
///
///
///
///
bool Update(T entity, Expression> expression, bool ignoreAllNull = false);
bool Update(T entity, Expression> expression, Expression> where);
bool Update(SqlSugarClient client, T entity, Expression> expression, Expression> where);
///
///
///
/// T
/// 忽略更新
/// Null不更新
///
//bool Update(T entity, List list = null, bool isNull = true);
//bool Update(List entity);
bool Update(Expression> where, Expression> columns);
#endregion update
DbResult UseTran(Action action);
DbResult UseTran(SqlSugarClient client, Action action);
bool UseTran2(Action action);
#region delete
int Delete(Expression> expression);
int Delete(object[] obj);
int Delete(object id);
bool DeleteTable();
#endregion delete
#region query
///
/// 根据条件查询分页数据
///
///
///
///
PagedInfo GetPages(Expression> where, PagerInfo parm);
PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, OrderByType orderEnum = OrderByType.Asc);
PagedInfo GetPages(Expression> where, PagerInfo parm, Expression> order, string orderType);
bool Any(Expression> expression);
ISugarQueryable Queryable();
List GetAll(bool useCache = false, int cacheSecond = 3600);
//ISugarQueryable Queryable(string tableName, string shortName);
//ISugarQueryable Queryable() where T1 : class where T2 : new();
List GetList(Expression> expression);
//Task> QueryableToListAsync(Expression> expression);
//string QueryableToJson(string select, Expression> expressionWhere);
//List QueryableToList(string tableName);
//(List, int) QueryableToPage(Expression> expression, int pageIndex = 0, int pageSize = 10);
//(List, int) QueryableToPage(Expression> expression, string order, int pageIndex = 0, int pageSize = 10);
//(List, int) QueryableToPage(Expression> expression, Expression> orderFiled, string orderBy, int pageIndex = 0, int pageSize = 10);
//(List, int) QueryableToPage(Expression> expression, Bootstrap.BootstrapParams bootstrap);
//List SqlQueryToList(string sql, object obj = null);
///
/// 获得一条数据
///
/// Expression>
///
T GetFirst(Expression> where);
T GetId(object pkValue);
///
/// 获得一条数据
///
/// string
///
//T GetFirst(string parm);
int Count(Expression> where);
#endregion query
#region Procedure
DataTable UseStoredProcedureToDataTable(string procedureName, List parameters);
(DataTable, List) UseStoredProcedureToTuple(string procedureName, List parameters);
#endregion Procedure
}
}