1862 lines
80 KiB
C#
1862 lines
80 KiB
C#
|
|
using Microsoft.EntityFrameworkCore.Storage;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Concurrent;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Data.Common;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Linq.Expressions;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using APT.Infrastructure.Core;
|
|||
|
|
namespace APT.Infrastructure.Api
|
|||
|
|
{
|
|||
|
|
public abstract class CommonApiController : BaseApiController
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取操作单元
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IUnitOfWork GetUnitOfWork<T>() where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.UnitWork();
|
|||
|
|
}
|
|||
|
|
readonly ServiceLocator _serviceLocator = ServiceLocator.Instance;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region old query
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(string id, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.GetEntity<T>(id, paths);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(Guid id, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.GetEntity<T>(id, paths);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(Expression<Func<T, bool>> expression, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity<T>(expression, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(Expression<Func<T, bool>> expression, BaseFilter fiter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity<T>(expression, fiter, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntities<T>(expression, filter, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">类型</typeparam>
|
|||
|
|
/// <param name="orderBy">排序</param>
|
|||
|
|
/// <param name="expression">lambd表达式</param>
|
|||
|
|
/// <param name="filter">过滤器</param>
|
|||
|
|
/// <param name="paths">需要关联查询的数据</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> ActionOrderEntities<T>(Action<IOrderable<T>> orderBy, Expression<Func<T, bool>> expression, BaseFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, orderBy, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">类型</typeparam>
|
|||
|
|
/// <param name="expression">lambd表达式</param>
|
|||
|
|
/// <param name="filter">过滤器</param>
|
|||
|
|
/// <param name="paths">需要关联查询的数据</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排序获取数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="sort"></param>
|
|||
|
|
/// <param name="order"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, string sort, string order, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, sort, order, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排序获取数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="sort"></param>
|
|||
|
|
/// <param name="order"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, Dictionary<string, string> orders, BaseFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, orders, paths);
|
|||
|
|
}
|
|||
|
|
///// <summary>
|
|||
|
|
///// 获取实体集合
|
|||
|
|
///// </summary>
|
|||
|
|
///// <param name="filter"></param>
|
|||
|
|
///// <returns></returns>
|
|||
|
|
//public PagedActionResult<T> GetPageEntities<T>(CommonPageFilter filter) where T : MesEntityBase, new()
|
|||
|
|
//{
|
|||
|
|
// _serviceLocator.RegisterType(typeof(CommonService<T>), typeof(ICommonService<T>));
|
|||
|
|
// var commonService = _serviceLocator.GetService<ICommonService<T>>();
|
|||
|
|
// Expression<Func<T, bool>> expression = t => true;
|
|||
|
|
// if (!string.IsNullOrEmpty(filter.Cid))
|
|||
|
|
// expression.And(i => i.CID == filter.Cid);
|
|||
|
|
// var page = commonService.GetPagerIEnumerable(expression, filter.Start, filter.Limit);
|
|||
|
|
// return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public PagedActionResult<T> GetPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
filter.Sort = "ID";
|
|||
|
|
var page = commonService.GetPageEntities<T>(expression, filter, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IEnumerable<TreeNode<T>> GetTreeOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, params string[] paths) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetTreeOrderEntities<T>(expression, filter, (!filter?.IsNoTranking) ?? true, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public PagedActionResult<T> ActionOrderPageEntities<T>(Action<IOrderable<T>> orderBy, Expression<Func<T, bool>> expression, BasePageFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = commonService.GetOrderPageEntities<T>(expression, filter, null, 0, 0, orderBy, (!filter?.IsNoTranking) ?? true, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 分页查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="pageFilter"></param>
|
|||
|
|
/// <param name="pageSize"></param>
|
|||
|
|
/// <param name="startIndex"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public PagedActionResult<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter, string[] selectField,
|
|||
|
|
params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = commonService.GetOrderPageEntities<T>(expression, pageFilter, selectField, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public PagedActionResult<T> GetOrderPageEntities<T>(Expression<Func<T, bool>> expression, BasePageFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = commonService.GetOrderPageEntities<T>(expression, filter, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<PagedActionResult<T>> ActionOrderPageEntitiesSync<T>(Action<IOrderable<T>> orderBy, Expression<Func<T, bool>> expression, BasePageFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = await commonService.GetOrderPageEntitiesSync<T>(expression, filter, null, 0, 0, orderBy, (!filter?.IsNoTranking) ?? true, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<PagedActionResult<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter filter, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = await commonService.GetOrderPageEntitiesSync<T>(expression, filter, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region notraking query
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(string id, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity<T>(t => t.ID == new Guid(id), null, notraking, paths);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(Expression<Func<T, bool>> expression, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity<T>(expression, null, notraking, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T GetEntity<T>(Expression<Func<T, bool>> expression, BaseFilter fiter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity<T>(expression, fiter, notraking, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public T GetEntityByRedis<T>(string key, Guid orgid) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntityByRedis<T>(key, orgid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public T GetEntityByRedis<T>(Guid key, Guid orgid) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntityByRedis<T>(key, orgid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<T> GetEntitiesByRedis<T>(BaseFilter filter) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntitiesByRedis<T>(filter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<T> GetEntitiesByGroupRedis<T>(BaseFilter filter, string groupValue) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntitiesByGroupRedis<T>(filter, groupValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<T> GetEntitiesByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntitiesByRedis<T>(expression, filter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<T> GetEntitiesByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter,
|
|||
|
|
params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntitiesTableByRedis<T>(expression, filter, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<T> GetEntitiesByRedis<T>(Expression<Func<T, bool>> expression, BaseFilter filter, string groupValue,
|
|||
|
|
params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntitiesByRedis<T>(expression, filter, groupValue, paths);
|
|||
|
|
}
|
|||
|
|
public PagedResultDto<T> GetOrderPageByRedis<T>(Expression<Func<T, bool>> expression, BasePageFilter pageFilter,
|
|||
|
|
params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderPageByRedis<T>(expression, pageFilter, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntities<T>(expression, filter, notraking, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">类型</typeparam>
|
|||
|
|
/// <param name="orderBy">排序</param>
|
|||
|
|
/// <param name="expression">lambd表达式</param>
|
|||
|
|
/// <param name="filter">过滤器</param>
|
|||
|
|
/// <param name="paths">需要关联查询的数据</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> ActionOrderEntities<T>(Action<IOrderable<T>> orderBy, Expression<Func<T, bool>> expression, BaseFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, orderBy, notraking, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">类型</typeparam>
|
|||
|
|
/// <param name="orderBy">排序</param>
|
|||
|
|
/// <param name="expression">lambd表达式</param>
|
|||
|
|
/// <param name="filter">过滤器</param>
|
|||
|
|
/// <param name="paths">需要关联查询的数据</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, notraking, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排序获取数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="sort"></param>
|
|||
|
|
/// <param name="order"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, string sort, string order, BaseFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
Dictionary<string, string> orders = new Dictionary<string, string>();
|
|||
|
|
orders[sort] = order;
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, orders, null, notraking, paths);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 排序获取数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="sort"></param>
|
|||
|
|
/// <param name="order"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<T> GetOrderEntities<T>(Expression<Func<T, bool>> expression, Dictionary<string, string> orders, BaseFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetOrderEntities<T>(expression, filter, orders, null, notraking, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<PagedActionResult<T>> GetPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
filter.Sort = "ID";
|
|||
|
|
var page = await commonService.GetOrderPageEntitiesSync(expression, filter, 0, 0, notraking, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<PagedActionResult<T>> ActionOrderPageEntitiesSync<T>(Action<IOrderable<T>> orderBy, Expression<Func<T, bool>> expression, BasePageFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = await commonService.GetOrderPageEntitiesSync(expression, filter, null, 0, 0, orderBy, notraking, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///获取排序的实体集合
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="orderBy"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <param name="paths"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public async Task<PagedActionResult<T>> GetOrderPageEntitiesSync<T>(Expression<Func<T, bool>> expression, BasePageFilter filter, bool notraking = false, params string[] paths) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
var page = await commonService.GetOrderPageEntitiesSync(expression, filter, null, 0, 0, null, notraking, paths);
|
|||
|
|
return new PagedActionResult<T>(page.Items, page.TotalCount);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取条数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <param name="filter"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int GetCount<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.Count(expression, filter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool IsAny<T>(Expression<Func<T, bool>> expression, BaseFilter filter) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.IsAny(expression, filter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool AddEntity<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.AddEntity(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T AddAndGetEntity<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.AddAndGetEntity(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntity<T>(string id) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntity<T>(Expression<Func<T, bool>> expression) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntity<T>(IEnumerable<T> entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntity<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 逻辑批量删除
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="ids"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchDeleteEntity<T>(List<Guid> ids) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.DeleteEntity<T>(i => ids.Contains(i.ID));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool RealDeleteEntity<T>(Expression<Func<T, bool>> expression) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool RealDeleteEntity<T>(IEnumerable<T> entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool RealDeleteEntity<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ids">id集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool RealBantchDeleteEntity<T>(List<Guid> ids) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.DeleteEntity<T>(i => ids.Contains(i.ID));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool UpdateEntity<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.UpdateEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 按字段更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool UpdateEntity<T>(T entity, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.UpdateEntity<T>(entity, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchAddEntity<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchAddEntity(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchUpdateEntity<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchUpdateEntity(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更具字段批量更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchUpdateEntity<T>(IEnumerable<T> entities, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchUpdateEntity(entities, updateField);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">批量保存</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchSaveEntity<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchSaveEntity(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region nocommit
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool AddEntityNoCommit<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.AddEntityNoCommit(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntityNoCommit<T>(string id) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntityNoCommit<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntityNoCommit<T>(Expression<Func<T, bool>> expression) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntityNoCommit<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntityNoCommit<T>(IEnumerable<T> entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool DeleteEntityNoCommit<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 逻辑批量删除
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="ids"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchDeleteEntityNoCommit<T>(List<Guid> ids) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.DeleteEntityNoCommit<T>(i => ids.Contains(i.ID));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool UpdateEntityNoCommit<T>(T entity) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.UpdateEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchAddEntityNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchAddEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool UpdateEntityNoCommit<T>(T entity, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.UpdateEntityNoCommit<T>(entity, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchUpdateEntityNoCommit<T>(IEnumerable<T> entities, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchUpdateEntityNoCommit(entities, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchUpdateEntityNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchUpdateEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">批量保存</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool BantchSaveEntityNoCommit<T>(IEnumerable<T> entities) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.BantchSaveEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 根据连接更新数据
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">实体数据</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void AddEntityByConn<T>(T entity, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.AddEntityByConn<T>(entity, conn);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接更新数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">实体数据集合</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void UpdateEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntitiesByConn<T>(entities, conn);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接更新数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">实体数据</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
/// <param name="updateField">更新字段</param>
|
|||
|
|
public void UpdateEntityByConn<T>(T entity, string conn, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntityByConn<T>(entity, conn, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression">表达式</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void DeleteEntityByConn<T>(Expression<Func<T, bool>> expression, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByConn<T>(expression, conn);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">数据实体</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void DeleteEntityByConn<T>(T entity, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByConn<T>(entity, conn);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id">主键</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void DeleteEntityByConn<T>(Guid id, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByConn<T>(id, conn);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">数据集合</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void DeleteEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntitiesByConn<T>(entities, conn);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">数据集合</param>
|
|||
|
|
/// <param name="conn">加密连接</param>
|
|||
|
|
public void AddEntitiesByConn<T>(IEnumerable<T> entities, string conn) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.AddEntitiesByConn<T>(entities, conn);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities"></param>
|
|||
|
|
/// <param name="conn"></param>
|
|||
|
|
/// <param name="updateField"></param>
|
|||
|
|
public void UpdateEntitiesByConn<T>(IEnumerable<T> entities, string conn, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntitiesByConn<T>(entities, conn, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 根据租户更新数据
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">实体数据</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void AddEntityByTenant<T>(T entity, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.AddEntityByTenant<T>(entity, Tenant);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户更新数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">实体数据集合</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void UpdateEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntitiesByTenant<T>(entities, Tenant);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户更新数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">实体数据</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
/// <param name="updateField">更新字段</param>
|
|||
|
|
public void UpdateEntityByTenant<T>(T entity, string Tenant, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntityByTenant<T>(entity, Tenant, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="expression">表达式</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void DeleteEntityByTenant<T>(Expression<Func<T, bool>> expression, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByTenant<T>(expression, Tenant);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity">数据实体</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void DeleteEntityByTenant<T>(T entity, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByTenant<T>(entity, Tenant);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id">主键</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void DeleteEntityByTenant<T>(Guid id, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntityByTenant<T>(id, Tenant);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户删除数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">数据集合</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void DeleteEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.DeleteEntitiesByTenant<T>(entities, Tenant);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities">数据集合</param>
|
|||
|
|
/// <param name="Tenant">加密租户</param>
|
|||
|
|
public void AddEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.AddEntitiesByTenant<T>(entities, Tenant);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库租户新增数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entities"></param>
|
|||
|
|
/// <param name="Tenant"></param>
|
|||
|
|
/// <param name="updateField"></param>
|
|||
|
|
public void UpdateEntitiesByTenant<T>(IEnumerable<T> entities, string Tenant, params string[] updateField) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntitiesByTenant<T>(entities, Tenant, updateField);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 树实体
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeAddEntityNoCommit<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeAddEntityNoCommit(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T TreeAddAndGetEntityNoCommit<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeAddAndGetEntityNoCommit(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntityNoCommit<T>(string id) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntityNoCommit<T>(Expression<Func<T, bool>> expression) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntityNoCommit<T>(IEnumerable<T> entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntityNoCommit<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 逻辑批量删除
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="ids"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchDeleteEntityNoCommit<T>(List<Guid> ids) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(i => ids.Contains(i.ID));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntityNoCommit<T>(string id) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntityNoCommit<T>(Expression<Func<T, bool>> expression) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntityNoCommit<T>(IEnumerable<T> entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntityNoCommit<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ids">id集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealBantchDeleteEntityNoCommit<T>(List<Guid> ids) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntityNoCommit<T>(i => ids.Contains(i.ID));
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeUpdateEntityNoCommit<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeUpdateEntityNoCommit(entity);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchAddEntityNoCommit<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchAddEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchUpdateEntityNoCommit<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchUpdateEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">批量保存</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchSaveEntityNoCommit<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchSaveEntityNoCommit(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 树实体
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeAddEntity<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeAddEntity(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public T TreeAddAndGetEntity<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeAddAndGetEntity(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntity<T>(string id) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntity<T>(Expression<Func<T, bool>> expression) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntity<T>(IEnumerable<T> entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeDeleteEntity<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 逻辑批量删除
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="ids"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchDeleteEntity<T>(List<Guid> ids) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
|
|||
|
|
return commonService.TreeDeleteEntity<T>(i => ids.Contains(i.ID));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntity<T>(string id) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(new Guid(id));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="expression"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntity<T>(Expression<Func<T, bool>> expression) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(expression);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntity<T>(IEnumerable<T> entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T"></typeparam>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealDeleteEntity<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(entity);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ids">id集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeRealBantchDeleteEntity<T>(List<Guid> ids) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
if (ids == null || !ids.Any()) return false;
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeDeleteEntity<T>(i => ids.Contains(i.ID));
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeUpdateEntity<T>(T entity) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeUpdateEntity(entity);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量添加实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集合</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchAddEntity<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchAddEntity(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量更新实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">实体集</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchUpdateEntity<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchUpdateEntity(entities);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entities">批量保存</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool TreeBantchSaveEntity<T>(IEnumerable<T> entities) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.TreeBantchSaveEntity(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除实体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable<TreeNode<T>> TreeOrderEntities<T>(Expression<Func<T, bool>> expression, BaseFilter filter, bool isTracking,
|
|||
|
|
params string[] paths) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetTreeOrderEntities<T>(expression, filter, isTracking, paths);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IEnumerable<T> GetTree<T>(string id, bool containCurrent = true, BaseFilter filter = null,
|
|||
|
|
params string[] paths) where T : TreeEntityBase<T>, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetTree<T>(id, containCurrent, filter, paths);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 执行SQL
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令。
|
|||
|
|
/// </summary>
|
|||
|
|
/// /// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="parameters">参数</param>
|
|||
|
|
/// <returns>受影响的行数</returns>
|
|||
|
|
public int ExecuteSqlCommand<T>(string sql, params object[] parameters) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteSqlCommand(sql, parameters);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="transactionalBehavior">事务行为</param>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="parameters">参数</param>
|
|||
|
|
/// <returns>受影响的行数</returns>
|
|||
|
|
public int ExecuteSqlCommand<T>(TransactionalBehavior transactionalBehavior, string sql, params object[] parameters) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteSqlCommand(transactionalBehavior, sql, parameters);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令返回reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="readerAction">reader委托</param>
|
|||
|
|
public void ExecuteReader<T>(string sql, ReaderColumn[] readerColumns, Action<DbDataReader> readerAction) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReader(sql, readerColumns, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令返回reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="parameters">参数</param>
|
|||
|
|
/// <param name="readerAction">reader委托</param>
|
|||
|
|
public void ExecuteReader<T>(string sql, ReaderColumn[] readerColumns, DbParameter[] parameters, Action<DbDataReader> readerAction) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReader(sql, readerColumns, parameters, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令返回reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="commandType">命令类型</param>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="parameters">参数</param>
|
|||
|
|
/// <param name="readerAction">reader委托</param>
|
|||
|
|
public void ExecuteReader<T>(CommandType commandType, string sql, ReaderColumn[] readerColumns, DbParameter[] parameters, Action<DbDataReader> readerAction) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReader(commandType, sql, readerColumns, parameters, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 创建一个原始 SQL 查询,该查询将返回给定泛型类型的元素。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="TElement">查询所返回对象的类型</typeparam>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="sql">SQL 查询字符串</param>
|
|||
|
|
/// <param name="parameters">要应用于 SQL 查询字符串的参数</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
//public IEnumerable<TElement> SqlQuery<TElement, T>(string sql, params object[] parameters) where T : MesEntityBase, new()
|
|||
|
|
//{
|
|||
|
|
// _serviceLocator.RegisterType(typeof(CommonService<T>), typeof(ICommonService<T>));
|
|||
|
|
// var commonService = _serviceLocator.GetService<ICommonService<T>>();
|
|||
|
|
// return commonService.SqlQuery<TElement>(sql, parameters);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 创建一个原始 SQL 查询,该查询将返回给定类型的元素。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <typeparam name="T">用于创建服务的实例类型</typeparam>
|
|||
|
|
/// <param name="elementType">查询所返回对象的类型</param>
|
|||
|
|
/// <param name="sql">SQL 查询字符串</param>
|
|||
|
|
/// <param name="parameters">要应用于 SQL 查询字符串的参数</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public IEnumerable SqlQuery<T>(Type elementType, string sql, ReaderColumn[] readerColumns, params Object[] parameters) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.SqlQuery(elementType, sql, readerColumns, parameters);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 对数据库执行给定的 DDL/DML 命令。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="commandType">命令类型</param>
|
|||
|
|
/// <param name="sql">命令字符串</param>
|
|||
|
|
/// <param name="parameters">参数</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int ExecuteNonQuery<T>(CommandType commandType, string sql, ReaderColumn[] readerColumns, DbParameter[] parameters) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteNonQuery(commandType, sql, readerColumns, parameters);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
public void ExecuteNonQueryByConn<T>(DataBaseType dataBaseType, string connString, CommandType commandType, string sql, DbParameter[] dbParameters) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteNonQueryByConn(dataBaseType, connString, commandType, sql, dbParameters);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="readerAction">执行委托</param>
|
|||
|
|
public void ExecuteReaderByConn<T>(DataBaseType dataBaseType, string connString, CommandType commandType,
|
|||
|
|
string sql, DbParameter[] dbParameters, Action<DbDataReader> readerAction) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderByConn(dataBaseType, connString, commandType, sql, dbParameters, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="pageIndex">分页索引 从1开始</param>
|
|||
|
|
/// <param name="pageLimit">每页条数 必填</param>
|
|||
|
|
/// <param name="readerAction">执行委托</param>
|
|||
|
|
public void ExecuteReaderPageByConn<T>(DataBaseType dataBaseType, string connString, CommandType commandType,
|
|||
|
|
string sql, DbParameter[] dbParameters, int pageIndex, int pageLimit, Action<DbDataReader> readerAction)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderPageByConn(dataBaseType, connString, commandType, sql,
|
|||
|
|
dbParameters, pageIndex, pageLimit, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取数据总条数。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <returns>数据总条数</returns>
|
|||
|
|
public int GetSqlCountByConn<T>(DataBaseType dataBaseType, string connString, CommandType commandType,
|
|||
|
|
string sql, DbParameter[] dbParameters)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetSqlCountByConn(dataBaseType, connString, commandType, sql, dbParameters);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取数据库连接对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
public DbConnection InitDbConnection<T>(DataBaseType dataBaseType, string connString)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.InitDbConnection(dataBaseType, connString);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取数据库连接对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
public DbConnection InitDbConnection(DataBaseType dataBaseType, string connString)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.InitDbConnection(dataBaseType, connString);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。 所有其他的列和行将被忽略。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
public object ExecuteScalarByConn<T>(DataBaseType dataBaseType, string connString, CommandType commandType, string sql, DbParameter[] dbParameters)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteScalarByConn(dataBaseType, connString, commandType, sql, dbParameters);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。 所有其他的列和行将被忽略。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="connString">连接字符串</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
public object ExecuteScalarByConn(DataBaseType dataBaseType, string connString, CommandType commandType, string sql, DbParameter[] dbParameters)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteScalarByConn(dataBaseType, connString, commandType, sql, dbParameters);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。 所有其他的列和行将被忽略。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">数据库连接对象</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
public object ExecuteScalarByConn(DataBaseType dataBaseType, DbConnection conn, CommandType commandType,
|
|||
|
|
string sql, bool close = true, params DbParameter[] dbParameters)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteScalarByConn(dataBaseType, conn, commandType, sql, close, dbParameters);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 执行查询,并返回查询所返回的结果集中第一行的第一列。 所有其他的列和行将被忽略。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">数据库连接对象</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
public object ExecuteScalarByConn<T>(DataBaseType dataBaseType, DbConnection conn, CommandType commandType,
|
|||
|
|
string sql, bool close = true, params DbParameter[] dbParameters)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.ExecuteScalarByConn(dataBaseType, conn, commandType, sql, close, dbParameters);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">连接对象</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="pageIndex">分页索引 从1开始</param>
|
|||
|
|
/// <param name="pageLimit">每页条数 必填</param>
|
|||
|
|
/// <param name="readerAction">执行委托</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
public void ExecuteReaderPageByConn(DataBaseType dataBaseType, DbConnection conn, CommandType commandType,
|
|||
|
|
string sql, DbParameter[] dbParameters, int pageIndex, int pageLimit, Action<DbDataReader> readerAction,
|
|||
|
|
bool close = true)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderPageByConn(dataBaseType, conn, commandType, sql,
|
|||
|
|
dbParameters, pageIndex, pageLimit, readerAction, close);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">连接对象</param>
|
|||
|
|
/// <param name="commandType">sql 类型</param>
|
|||
|
|
/// <param name="sql">sql</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="pageIndex">分页索引 从1开始</param>
|
|||
|
|
/// <param name="pageLimit">每页条数 必填</param>
|
|||
|
|
/// <param name="readerAction">执行委托</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
public void ExecuteReaderPageByConn<T>(DataBaseType dataBaseType, DbConnection conn, CommandType commandType,
|
|||
|
|
string sql, DbParameter[] dbParameters, int pageIndex, int pageLimit, Action<DbDataReader> readerAction,
|
|||
|
|
bool close = true)
|
|||
|
|
where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderPageByConn(dataBaseType, conn, commandType, sql,
|
|||
|
|
dbParameters, pageIndex, pageLimit, readerAction, close);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">连接对象</param>
|
|||
|
|
/// <param name="commandType">指令类型</param>
|
|||
|
|
/// <param name="sql">SQL语句</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="readerAction">委托</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
public void ExecuteReaderByConn<T>(DataBaseType dataBaseType, DbConnection conn, CommandType commandType, string sql,
|
|||
|
|
DbParameter[] dbParameters, Action<DbDataReader> readerAction, bool close = true) where T : MesEntityBase, new()
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderByConn(dataBaseType, conn, commandType, sql,
|
|||
|
|
dbParameters, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">连接对象</param>
|
|||
|
|
/// <param name="commandType">指令类型</param>
|
|||
|
|
/// <param name="sql">SQL语句</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="readerAction">委托</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
public void ExecuteReaderByConn(DataBaseType dataBaseType, DbConnection conn, CommandType commandType, string sql,
|
|||
|
|
DbParameter[] dbParameters, Action<DbDataReader> readerAction, bool close = true)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteReaderByConn(dataBaseType, conn, commandType, sql,
|
|||
|
|
dbParameters, readerAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据数据库连接对数据库执行给定的 DDL/DML 命令获取Reader。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataBaseType">数据库类型</param>
|
|||
|
|
/// <param name="conn">连接对象</param>
|
|||
|
|
/// <param name="commandType">指令类型</param>
|
|||
|
|
/// <param name="sql">SQL语句</param>
|
|||
|
|
/// <param name="dbParameters">参数</param>
|
|||
|
|
/// <param name="readerAction">委托</param>
|
|||
|
|
/// <param name="close">是否自动关闭连接</param>
|
|||
|
|
public void ExecuteNonQueryByConn(DataBaseType dataBaseType, DbConnection conn, CommandType commandType, string sql, DbParameter[] dbParameters, bool close = true)
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.ExecuteNonQueryByConn(dataBaseType, conn, commandType, sql,
|
|||
|
|
dbParameters, close);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public T AddAndGetEntity_noneBase<T>(T entity) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.AddAndGetEntity_noneBase(entity);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void BantchAddEntity_noneBase<T>(IEnumerable<T> entities) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.AddEntities_noneBase(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void BantchUpdateEntity_noneBase<T>(IEnumerable<T> entities) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
commonService.UpdateEntities_noneBase(entities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public T GetEntity_noneBase<T>(Expression<Func<T, bool>> expressions) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntity_noneBase(expressions);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<T> GetEntities_noneBase<T>(Expression<Func<T, bool>> expressions) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.GetEntities_noneBase(expressions);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool DeleteEntity_noneBase<T>(Expression<Func<T, bool>> expression) where T : class
|
|||
|
|
{
|
|||
|
|
var commonService = _serviceLocator.GetService<ICommonService>();
|
|||
|
|
return commonService.DeleteEntity_noneBase(expression);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|