仓储新增常用方法
This commit is contained in:
parent
01cd8aaf15
commit
ec5ea3ef9b
@ -3,6 +3,7 @@ using SqlSugar;
|
|||||||
using SqlSugar.IOC;
|
using SqlSugar.IOC;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ namespace ZR.Repository
|
|||||||
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
||||||
{
|
{
|
||||||
public ISqlSugarClient Context;
|
public ISqlSugarClient Context;
|
||||||
public BaseRepository(string configId = "0") //: base(dbContext)
|
public BaseRepository(string configId = "0")
|
||||||
{
|
{
|
||||||
Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择
|
Context = DbScoped.SugarScope.GetConnection(configId);//根据类传入的ConfigId自动选择
|
||||||
}
|
}
|
||||||
@ -192,40 +193,45 @@ namespace ZR.Repository
|
|||||||
}
|
}
|
||||||
#endregion update
|
#endregion update
|
||||||
|
|
||||||
//public DbResult<bool> UseTran(Action action)
|
public DbResult<bool> UseTran(Action action)
|
||||||
//{
|
{
|
||||||
// var result = base.Context.Ado.UseTran(() => action());
|
var result = Context.Ado.UseTran(() => action());
|
||||||
// return result;
|
return result;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public DbResult<bool> UseTran(SqlSugarClient client, Action action)
|
public DbResult<bool> UseTran(SqlSugarClient client, Action action)
|
||||||
//{
|
{
|
||||||
// var result = client.Ado.UseTran(() => action());
|
var result = client.Ado.UseTran(() => action());
|
||||||
// return result;
|
return result;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public bool UseTran2(Action action)
|
public bool UseTran2(Action action)
|
||||||
//{
|
{
|
||||||
// var result = base.Context.Ado.UseTran(() => action());
|
var result = Context.Ado.UseTran(() => action());
|
||||||
// return result.IsSuccess;
|
return result.IsSuccess;
|
||||||
//}
|
}
|
||||||
|
|
||||||
#region delete
|
#region delete
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除表达式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="expression"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public int Delete(Expression<Func<T, bool>> expression)
|
public int Delete(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
return Context.Deleteable<T>().Where(expression).ExecuteCommand();
|
return Context.Deleteable<T>().Where(expression).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public bool Delete<PkType>(PkType[] primaryKeyValues)
|
/// <summary>
|
||||||
//{
|
/// 批量删除
|
||||||
// return base.Context.Deleteable<T>().In(primaryKeyValues).ExecuteCommand() > 0;
|
/// </summary>
|
||||||
//}
|
/// <param name="obj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
//public int Delete(object[] obj)
|
public int Delete(object[] obj)
|
||||||
//{
|
{
|
||||||
// return Context.Deleteable<T>().In(obj).ExecuteCommand();
|
return Context.Deleteable<T>().In(obj).ExecuteCommand();
|
||||||
//}
|
}
|
||||||
public int Delete(object id)
|
public int Delete(object id)
|
||||||
{
|
{
|
||||||
return Context.Deleteable<T>(id).ExecuteCommand();
|
return Context.Deleteable<T>(id).ExecuteCommand();
|
||||||
@ -370,10 +376,10 @@ namespace ZR.Repository
|
|||||||
/// <param name="procedureName"></param>
|
/// <param name="procedureName"></param>
|
||||||
/// <param name="parameters"></param>
|
/// <param name="parameters"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters)
|
public DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters)
|
||||||
//{
|
{
|
||||||
// return base.Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters);
|
return Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters);
|
||||||
//}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 带output返回值
|
/// 带output返回值
|
||||||
@ -384,11 +390,11 @@ namespace ZR.Repository
|
|||||||
/// <param name="procedureName"></param>
|
/// <param name="procedureName"></param>
|
||||||
/// <param name="parameters"></param>
|
/// <param name="parameters"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public (DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters)
|
public (DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters)
|
||||||
//{
|
{
|
||||||
// var result = (base.Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters), parameters);
|
var result = (Context.Ado.UseStoredProcedure().GetDataTable(procedureName, parameters), parameters);
|
||||||
// return result;
|
return result;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@ -81,18 +81,16 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
#endregion update
|
#endregion update
|
||||||
|
|
||||||
//DbResult<bool> UseTran(Action action);
|
DbResult<bool> UseTran(Action action);
|
||||||
|
|
||||||
//DbResult<bool> UseTran(SqlSugarClient client, Action action);
|
DbResult<bool> UseTran(SqlSugarClient client, Action action);
|
||||||
|
|
||||||
//bool UseTran2(Action action);
|
bool UseTran2(Action action);
|
||||||
|
|
||||||
#region delete
|
#region delete
|
||||||
|
|
||||||
int Delete(Expression<Func<T, bool>> expression);
|
int Delete(Expression<Func<T, bool>> expression);
|
||||||
|
int Delete(object[] obj);
|
||||||
//bool Delete<PkType>(PkType[] primaryKeyValues);
|
|
||||||
//int Delete(object[] obj);
|
|
||||||
int Delete(object id);
|
int Delete(object id);
|
||||||
bool DeleteTable();
|
bool DeleteTable();
|
||||||
|
|
||||||
@ -156,9 +154,9 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
#region Procedure
|
#region Procedure
|
||||||
|
|
||||||
//DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
|
DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
|
||||||
|
|
||||||
//(DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
|
(DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
|
||||||
|
|
||||||
#endregion Procedure
|
#endregion Procedure
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user