fix: format the code. #236

This commit is contained in:
anjoy8 2022-03-14 15:15:05 +08:00
parent cf457503ae
commit 1093a7b76a
10 changed files with 197 additions and 258 deletions

View File

@ -1514,22 +1514,22 @@
时间:2020-4-3 20:31:26
</summary>
</member>
<member name="P:Blog.Core.Model.PaginationModel.intPageIndex">
<member name="P:Blog.Core.Model.PaginationModel.PageIndex">
<summary>
当前页
</summary>
</member>
<member name="P:Blog.Core.Model.PaginationModel.intPageSize">
<member name="P:Blog.Core.Model.PaginationModel.PageSize">
<summary>
每页大小
</summary>
</member>
<member name="P:Blog.Core.Model.PaginationModel.strOrderByFileds">
<member name="P:Blog.Core.Model.PaginationModel.OrderByFileds">
<summary>
排序字段(例如:id desc,time asc)
</summary>
</member>
<member name="P:Blog.Core.Model.PaginationModel.conditions">
<member name="P:Blog.Core.Model.PaginationModel.Conditions">
<summary>
查询条件( 例如:id = 1 and name = 小明)
</summary>

View File

@ -735,6 +735,7 @@
<param name="passwordLibServices"></param>
<param name="blogApi"></param>
<param name="doubanApi"></param>
<param name="httpPollyHelper"></param>
</member>
<member name="M:Blog.Core.Controllers.ValuesController.Get">
<summary>

View File

@ -1,8 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -1,12 +0,0 @@
using System;
namespace Blog.Core.ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

View File

@ -26,32 +26,32 @@ namespace Blog.Core.IServices.BASE
Task<bool> DeleteByIds(object[] ids);
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(TEntity entity, string where);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "");
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string where = "");
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(string where);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression,string strOrderByFileds);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(string strWhere, string strOrderByFileds);
Task<List<TEntity>> QuerySql(string strSql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string strSql, SugarParameter[] parameters = null);
Task<List<TEntity>> Query(string where, string orderByFields);
Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFields);
Task<List<TEntity>> Query(string where, int top, string orderByFields);
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);
Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields);
Task<List<TEntity>> Query(string where, int pageIndex, int pageSize, string orderByFields);
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Blog.Core.Model
namespace Blog.Core.Model
{
/// <summary>
/// 所需分页参数
@ -14,18 +10,18 @@ namespace Blog.Core.Model
/// <summary>
/// 当前页
/// </summary>
public int intPageIndex { get; set; } = 1;
public int PageIndex { get; set; } = 1;
/// <summary>
/// 每页大小
/// </summary>
public int intPageSize { get; set; } = 10;
public int PageSize { get; set; } = 10;
/// <summary>
/// 排序字段(例如:id desc,time asc)
/// </summary>
public string strOrderByFileds { get; set; }
public string OrderByFileds { get; set; }
/// <summary>
/// 查询条件( 例如:id = 1 and name = 小明)
/// </summary>
public string conditions { get; set; }
public string Conditions { get; set; }
}
}

View File

@ -16,7 +16,7 @@ namespace Blog.Core.Repository.Base
public class BaseRepository<TEntity> : IBaseRepository<TEntity> where TEntity : class, new()
{
private readonly IUnitOfWork _unitOfWork;
private SqlSugarScope _dbBase;
private readonly SqlSugarScope _dbBase;
private ISqlSugarClient _db
{
@ -42,10 +42,7 @@ namespace Blog.Core.Repository.Base
}
}
public ISqlSugarClient Db
{
get { return _db; }
}
public ISqlSugarClient Db => _db;
public BaseRepository(IUnitOfWork unitOfWork)
{
@ -148,16 +145,14 @@ namespace Blog.Core.Repository.Base
return await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
}
public async Task<bool> Update(TEntity entity, string strWhere)
public async Task<bool> Update(TEntity entity, string where)
{
//return await Task.Run(() => _db.Updateable(entity).Where(strWhere).ExecuteCommand() > 0);
return await _db.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync();
return await _db.Updateable(entity).Where(where).ExecuteCommandHasChangeAsync();
}
public async Task<bool> Update(string strSql, SugarParameter[] parameters = null)
public async Task<bool> Update(string sql, SugarParameter[] parameters = null)
{
//return await Task.Run(() => _db.Ado.ExecuteCommand(strSql, parameters) > 0);
return await _db.Ado.ExecuteCommandAsync(strSql, parameters) > 0;
return await _db.Ado.ExecuteCommandAsync(sql, parameters) > 0;
}
public async Task<bool> Update(object operateAnonymousObjects)
@ -169,24 +164,9 @@ namespace Blog.Core.Repository.Base
TEntity entity,
List<string> lstColumns = null,
List<string> lstIgnoreColumns = null,
string strWhere = ""
string where = ""
)
{
//IUpdateable<TEntity> up = await Task.Run(() => _db.Updateable(entity));
//if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0)
//{
// up = await Task.Run(() => up.IgnoreColumns(it => lstIgnoreColumns.Contains(it)));
//}
//if (lstColumns != null && lstColumns.Count > 0)
//{
// up = await Task.Run(() => up.UpdateColumns(it => lstColumns.Contains(it)));
//}
//if (!string.IsNullOrEmpty(strWhere))
//{
// up = await Task.Run(() => up.Where(strWhere));
//}
//return await Task.Run(() => up.ExecuteCommand()) > 0;
IUpdateable<TEntity> up = _db.Updateable(entity);
if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0)
{
@ -196,9 +176,9 @@ namespace Blog.Core.Repository.Base
{
up = up.UpdateColumns(lstColumns.ToArray());
}
if (!string.IsNullOrEmpty(strWhere))
if (!string.IsNullOrEmpty(where))
{
up = up.Where(strWhere);
up = up.Where(where);
}
return await up.ExecuteCommandHasChangeAsync();
}
@ -210,8 +190,6 @@ namespace Blog.Core.Repository.Base
/// <returns></returns>
public async Task<bool> Delete(TEntity entity)
{
//var i = await Task.Run(() => _db.Deleteable(entity).ExecuteCommand());
//return i > 0;
return await _db.Deleteable(entity).ExecuteCommandHasChangeAsync();
}
@ -222,8 +200,6 @@ namespace Blog.Core.Repository.Base
/// <returns></returns>
public async Task<bool> DeleteById(object id)
{
//var i = await Task.Run(() => _db.Deleteable<TEntity>(id).ExecuteCommand());
//return i > 0;
return await _db.Deleteable<TEntity>(id).ExecuteCommandHasChangeAsync();
}
@ -234,8 +210,6 @@ namespace Blog.Core.Repository.Base
/// <returns></returns>
public async Task<bool> DeleteByIds(object[] ids)
{
//var i = await Task.Run(() => _db.Deleteable<TEntity>().In(ids).ExecuteCommand());
//return i > 0;
return await _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync();
}
@ -255,12 +229,11 @@ namespace Blog.Core.Repository.Base
/// 功能描述:查询数据列表
/// 作  者:Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="where">条件</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere)
public async Task<List<TEntity>> Query(string where)
{
//return await Task.Run(() => _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync();
return await _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync();
}
/// <summary>
@ -293,11 +266,11 @@ namespace Blog.Core.Repository.Base
/// <typeparam name="TResult"></typeparam>
/// <param name="whereExpression">过滤条件</param>
/// <param name="expression">查询实体条件</param>
/// <param name="strOrderByFileds">排序条件</param>
/// <param name="orderByFields">排序条件</param>
/// <returns></returns>
public async Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds)
public async Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields)
{
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync();
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Select(expression).ToListAsync();
}
/// <summary>
@ -305,12 +278,11 @@ namespace Blog.Core.Repository.Base
/// 作  者:Blog.Core
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds)
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync();
return await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(orderByFields != null, orderByFields).ToListAsync();
}
/// <summary>
/// 功能描述:查询一个列表
@ -329,13 +301,12 @@ namespace Blog.Core.Repository.Base
/// 功能描述:查询一个列表
/// 作  者:Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere, string strOrderByFileds)
public async Task<List<TEntity>> Query(string where, string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync();
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).ToListAsync();
}
@ -344,55 +315,53 @@ namespace Blog.Core.Repository.Base
/// 作  者:Blog.Core
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="top">前N条</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression,
int intTop,
string strOrderByFileds)
int top,
string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync();
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(whereExpression != null, whereExpression).Take(top).ToListAsync();
}
/// <summary>
/// 功能描述:查询前N条数据
/// 作  者:Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="top">前N条</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intTop,
string strOrderByFileds)
string where,
int top,
string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync();
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields).WhereIF(!string.IsNullOrEmpty(where), where).Take(top).ToListAsync();
}
/// <summary>
/// 根据sql语句查询
/// </summary>
/// <param name="strSql">完整的sql语句</param>
/// <param name="sql">完整的sql语句</param>
/// <param name="parameters">参数</param>
/// <returns>泛型集合</returns>
public async Task<List<TEntity>> QuerySql(string strSql, SugarParameter[] parameters = null)
public async Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null)
{
return await _db.Ado.SqlQueryAsync<TEntity>(strSql, parameters);
return await _db.Ado.SqlQueryAsync<TEntity>(sql, parameters);
}
/// <summary>
/// 根据sql语句查询
/// </summary>
/// <param name="strSql">完整的sql语句</param>
/// <param name="sql">完整的sql语句</param>
/// <param name="parameters">参数</param>
/// <returns>DataTable</returns>
public async Task<DataTable> QueryTable(string strSql, SugarParameter[] parameters = null)
public async Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null)
{
return await _db.Ado.GetDataTableAsync(strSql, parameters);
return await _db.Ado.GetDataTableAsync(sql, parameters);
}
/// <summary>
@ -400,38 +369,38 @@ namespace Blog.Core.Repository.Base
/// 作  者:Blog.Core
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="pageIndex">页码下标0</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression,
int intPageIndex,
int intPageSize,
string strOrderByFileds)
int pageIndex,
int pageSize,
string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize);
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields)
.WhereIF(whereExpression != null, whereExpression).ToPageListAsync(pageIndex, pageSize);
}
/// <summary>
/// 功能描述:分页查询
/// 作  者:Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="pageIndex">页码下标0</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intPageIndex,
int intPageSize,
string where,
int pageIndex,
int pageSize,
string strOrderByFileds)
string orderByFields)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize);
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields)
.WhereIF(!string.IsNullOrEmpty(where), where).ToPageListAsync(pageIndex, pageSize);
}
@ -440,20 +409,20 @@ namespace Blog.Core.Repository.Base
/// 分页查询[使用版本,其他分页未测试]
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="pageIndex">页码下标0</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFields">排序字段如name asc,age desc</param>
/// <returns></returns>
public async Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null)
public async Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null)
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable<TEntity>()
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields)
.WhereIF(whereExpression != null, whereExpression)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
.ToPageListAsync(pageIndex, pageSize, totalCount);
return new PageModel<TEntity>(intPageIndex, totalCount, intPageSize, list);
return new PageModel<TEntity>(pageIndex, totalCount, pageSize, list);
}
@ -490,26 +459,26 @@ namespace Blog.Core.Repository.Base
/// <param name="joinExpression">关联表达式</param>
/// <param name="selectExpression">返回表达式</param>
/// <param name="whereExpression">查询表达式</param>
/// <param name="intPageIndex">页码</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段</param>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFields">排序字段</param>
/// <returns></returns>
public async Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereExpression,
int intPageIndex = 1,
int intPageSize = 20,
string strOrderByFileds = null)
int pageIndex = 1,
int pageSize = 20,
string orderByFields = null)
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable<T, T2>(joinExpression)
.Select(selectExpression)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields)
.WhereIF(whereExpression != null, whereExpression)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
return new PageModel<TResult>(intPageIndex, totalCount, intPageSize, list);
.ToPageListAsync(pageIndex, pageSize, totalCount);
return new PageModel<TResult>(pageIndex, totalCount, pageSize, list);
}
/// <summary>
@ -521,27 +490,27 @@ namespace Blog.Core.Repository.Base
/// <param name="joinExpression">关联表达式</param>
/// <param name="selectExpression">返回表达式</param>
/// <param name="whereExpression">查询表达式</param>
/// <param name="intPageIndex">页码</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段</param>
/// <param name="groupExpression">group表达式</param>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFields">排序字段</param>
/// <returns></returns>
public async Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereExpression,
Expression<Func<T, object>> groupExpression,
int intPageIndex = 1,
int intPageSize = 20,
string strOrderByFileds = null)
int pageIndex = 1,
int pageSize = 20,
string orderByFields = null)
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable<T, T2>(joinExpression).GroupBy(groupExpression)
.Select(selectExpression)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.OrderByIF(!string.IsNullOrEmpty(orderByFields), orderByFields)
.WhereIF(whereExpression != null, whereExpression)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
return new PageModel<TResult>(intPageIndex, totalCount, intPageSize, list);
.ToPageListAsync(pageIndex, pageSize, totalCount);
return new PageModel<TResult>(pageIndex, totalCount, pageSize, list);
}
//var exp = Expressionable.Create<ProjectToUser>()

View File

@ -74,9 +74,9 @@ namespace Blog.Core.IRepository.Base
/// 根据model更新带where条件
/// </summary>
/// <param name="entity"></param>
/// <param name="strWhere"></param>
/// <param name="where"></param>
/// <returns></returns>
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(TEntity entity, string where);
Task<bool> Update(object operateAnonymousObjects);
/// <summary>
@ -85,9 +85,9 @@ namespace Blog.Core.IRepository.Base
/// <param name="entity"></param>
/// <param name="lstColumns"></param>
/// <param name="lstIgnoreColumns"></param>
/// <param name="strWhere"></param>
/// <param name="where"></param>
/// <returns></returns>
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "");
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string where = "");
/// <summary>
/// 查询
@ -98,9 +98,9 @@ namespace Blog.Core.IRepository.Base
/// <summary>
/// 带sql where查询
/// </summary>
/// <param name="strWhere"></param>
/// <param name="where"></param>
/// <returns></returns>
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(string where);
/// <summary>
/// 根据表达式查询
@ -123,31 +123,31 @@ namespace Blog.Core.IRepository.Base
/// <typeparam name="TResult"></typeparam>
/// <param name="expression"></param>
/// <param name="whereExpression"></param>
/// <param name="strOrderByFileds"></param>
/// <param name="orderByFields"></param>
/// <returns></returns>
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFields);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(string strWhere, string strOrderByFileds);
Task<List<TEntity>> Query(string where, string orderByFields);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intTop, string strOrderByFileds);
Task<List<TEntity>> QuerySql(string strSql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string strSql, SugarParameter[] parameters = null);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string orderByFields);
Task<List<TEntity>> Query(string where, int intTop, string orderByFields);
Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null);
Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null);
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);
Expression<Func<TEntity, bool>> whereExpression, int pageIndex, int pageSize, string orderByFields);
Task<List<TEntity>> Query(string where, int pageIndex, int pageSize, string orderByFields);
/// <summary>
/// 根据表达式,排序字段,分页查询
/// </summary>
/// <param name="whereExpression"></param>
/// <param name="intPageIndex"></param>
/// <param name="intPageSize"></param>
/// <param name="strOrderByFileds"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="orderByFields"></param>
/// <returns></returns>
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int pageIndex = 1, int pageSize = 20, string orderByFields = null);
/// <summary>
/// 三表联查
@ -174,17 +174,17 @@ namespace Blog.Core.IRepository.Base
/// <param name="joinExpression"></param>
/// <param name="selectExpression"></param>
/// <param name="whereExpression"></param>
/// <param name="intPageIndex"></param>
/// <param name="intPageSize"></param>
/// <param name="strOrderByFileds"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="orderByFields"></param>
/// <returns></returns>
Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereExpression,
int intPageIndex = 1,
int intPageSize = 20,
string strOrderByFileds = null);
int pageIndex = 1,
int pageSize = 20,
string orderByFields = null);
/// <summary>
/// 两表联合查询-分页-分组
@ -196,17 +196,17 @@ namespace Blog.Core.IRepository.Base
/// <param name="selectExpression"></param>
/// <param name="whereExpression"></param>
/// <param name="groupExpression"></param>
/// <param name="intPageIndex"></param>
/// <param name="intPageSize"></param>
/// <param name="strOrderByFileds"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="orderByFields"></param>
/// <returns></returns>
Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereExpression,
Expression<Func<T, object>> groupExpression,
int intPageIndex = 1,
int intPageSize = 20,
string strOrderByFileds = null);
int pageIndex = 1,
int pageSize = 20,
string orderByFields = null);
}
}

View File

@ -72,9 +72,9 @@ namespace Blog.Core.Services.BASE
{
return await BaseDal.Update(entity);
}
public async Task<bool> Update(TEntity entity, string strWhere)
public async Task<bool> Update(TEntity entity, string where)
{
return await BaseDal.Update(entity, strWhere);
return await BaseDal.Update(entity, where);
}
public async Task<bool> Update(object operateAnonymousObjects)
{
@ -85,10 +85,10 @@ namespace Blog.Core.Services.BASE
TEntity entity,
List<string> lstColumns = null,
List<string> lstIgnoreColumns = null,
string strWhere = ""
string where = ""
)
{
return await BaseDal.Update(entity, lstColumns, lstIgnoreColumns, strWhere);
return await BaseDal.Update(entity, lstColumns, lstIgnoreColumns, where);
}
@ -138,11 +138,11 @@ namespace Blog.Core.Services.BASE
/// 功能描述:查询数据列表
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="where">条件</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere)
public async Task<List<TEntity>> Query(string where)
{
return await BaseDal.Query(strWhere);
return await BaseDal.Query(where);
}
/// <summary>
@ -175,11 +175,11 @@ namespace Blog.Core.Services.BASE
/// <typeparam name="TResult"></typeparam>
/// <param name="whereExpression">过滤条件</param>
/// <param name="expression">查询实体条件</param>
/// <param name="strOrderByFileds">排序条件</param>
/// <param name="orderByFileds">排序条件</param>
/// <returns></returns>
public async Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression,string strOrderByFileds)
public async Task<List<TResult>> Query<TResult>(Expression<Func<TEntity, TResult>> expression, Expression<Func<TEntity, bool>> whereExpression,string orderByFileds)
{
return await BaseDal.Query(expression, whereExpression, strOrderByFileds);
return await BaseDal.Query(expression, whereExpression, orderByFileds);
}
/// <summary>
@ -194,44 +194,44 @@ namespace Blog.Core.Services.BASE
return await BaseDal.Query(whereExpression, orderByExpression, isAsc);
}
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds)
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string orderByFileds)
{
return await BaseDal.Query(whereExpression, strOrderByFileds);
return await BaseDal.Query(whereExpression, orderByFileds);
}
/// <summary>
/// 功能描述:查询一个列表
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="orderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere, string strOrderByFileds)
public async Task<List<TEntity>> Query(string where, string orderByFileds)
{
return await BaseDal.Query(strWhere, strOrderByFileds);
return await BaseDal.Query(where, orderByFileds);
}
/// <summary>
/// 根据sql语句查询
/// </summary>
/// <param name="strSql">完整的sql语句</param>
/// <param name="sql">完整的sql语句</param>
/// <param name="parameters">参数</param>
/// <returns>泛型集合</returns>
public async Task<List<TEntity>> QuerySql(string strSql, SugarParameter[] parameters = null)
public async Task<List<TEntity>> QuerySql(string sql, SugarParameter[] parameters = null)
{
return await BaseDal.QuerySql(strSql, parameters);
return await BaseDal.QuerySql(sql, parameters);
}
/// <summary>
/// 根据sql语句查询
/// </summary>
/// <param name="strSql">完整的sql语句</param>
/// <param name="sql">完整的sql语句</param>
/// <param name="parameters">参数</param>
/// <returns>DataTable</returns>
public async Task<DataTable> QueryTable(string strSql, SugarParameter[] parameters = null)
public async Task<DataTable> QueryTable(string sql, SugarParameter[] parameters = null)
{
return await BaseDal.QueryTable(strSql, parameters);
return await BaseDal.QueryTable(sql, parameters);
}
/// <summary>
@ -239,28 +239,28 @@ namespace Blog.Core.Services.BASE
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="top">前N条</param>
/// <param name="orderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds)
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int top, string orderByFileds)
{
return await BaseDal.Query(whereExpression, intTop, strOrderByFileds);
return await BaseDal.Query(whereExpression, top, orderByFileds);
}
/// <summary>
/// 功能描述:查询前N条数据
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="top">前N条</param>
/// <param name="orderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intTop,
string strOrderByFileds)
string where,
int top,
string orderByFileds)
{
return await BaseDal.Query(strWhere, intTop, strOrderByFileds);
return await BaseDal.Query(where, top, orderByFileds);
}
/// <summary>
@ -268,50 +268,50 @@ namespace Blog.Core.Services.BASE
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="pageIndex">页码下标0</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression,
int intPageIndex,
int intPageSize,
string strOrderByFileds)
int pageIndex,
int pageSize,
string orderByFileds)
{
return await BaseDal.Query(
whereExpression,
intPageIndex,
intPageSize,
strOrderByFileds);
pageIndex,
pageSize,
orderByFileds);
}
/// <summary>
/// 功能描述:分页查询
/// 作  者:AZLinli.Blog.Core
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <param name="where">条件</param>
/// <param name="pageIndex">页码下标0</param>
/// <param name="pageSize">页大小</param>
/// <param name="orderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intPageIndex,
int intPageSize,
string strOrderByFileds)
string where,
int pageIndex,
int pageSize,
string orderByFileds)
{
return await BaseDal.Query(
strWhere,
intPageIndex,
intPageSize,
strOrderByFileds);
where,
pageIndex,
pageSize,
orderByFileds);
}
public async Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression,
int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null)
int pageIndex = 1, int pageSize = 20, string orderByFileds = null)
{
return await BaseDal.QueryPage(whereExpression,
intPageIndex, intPageSize, strOrderByFileds);
pageIndex, pageSize, orderByFileds);
}
public async Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(Expression<Func<T, T2, T3, object[]>> joinExpression, Expression<Func<T, T2, T3, TResult>> selectExpression, Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new()
@ -320,8 +320,8 @@ namespace Blog.Core.Services.BASE
}
public async Task<PageModel<TEntity>> QueryPage(PaginationModel pagination)
{
var express = DynamicLinqFactory.CreateLambda<TEntity>(pagination.conditions);
return await QueryPage(express, pagination.intPageIndex, pagination.intPageSize, pagination.strOrderByFileds);
var express = DynamicLinqFactory.CreateLambda<TEntity>(pagination.Conditions);
return await QueryPage(express, pagination.PageIndex, pagination.PageSize, pagination.OrderByFileds);
}
}

View File

@ -51,8 +51,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventBus", "EventBus", "{A5
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.EventBus", "Blog.Core.EventBus\Blog.Core.EventBus.csproj", "{17C9E9DC-E926-4C90-9025-3DAC55D7EDA3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.ConsoleApp", "Blog.Core.ConsoleApp\Blog.Core.ConsoleApp.csproj", "{0B3265A9-6716-4D28-8648-C64D5E692ACA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.Gateway", "Blog.Core.Gateway\Blog.Core.Gateway.csproj", "{A11C0DF2-1E13-4EED-BA49-44A57136B189}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blog.Core.Serilog.Es", "Blog.Core.Serilog.Es\Blog.Core.Serilog.Es.csproj", "{52AFAB53-D1CA-4014-8B63-3550FDCDA6E1}"
@ -109,10 +107,6 @@ Global
{17C9E9DC-E926-4C90-9025-3DAC55D7EDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17C9E9DC-E926-4C90-9025-3DAC55D7EDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17C9E9DC-E926-4C90-9025-3DAC55D7EDA3}.Release|Any CPU.Build.0 = Release|Any CPU
{0B3265A9-6716-4D28-8648-C64D5E692ACA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B3265A9-6716-4D28-8648-C64D5E692ACA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B3265A9-6716-4D28-8648-C64D5E692ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B3265A9-6716-4D28-8648-C64D5E692ACA}.Release|Any CPU.Build.0 = Release|Any CPU
{A11C0DF2-1E13-4EED-BA49-44A57136B189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A11C0DF2-1E13-4EED-BA49-44A57136B189}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A11C0DF2-1E13-4EED-BA49-44A57136B189}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -133,7 +127,6 @@ Global
{300A8113-8033-4184-BE28-FC48D8349CD0} = {EDA8901E-541E-4ADC-B71E-59697D5F9549}
{52D318A2-F44E-4CB7-8DD4-483357D4333F} = {047A9723-9AAC-42E3-8C69-B3835F15FF96}
{17C9E9DC-E926-4C90-9025-3DAC55D7EDA3} = {A592C96A-4E44-4F2A-AC21-30683AF6C493}
{0B3265A9-6716-4D28-8648-C64D5E692ACA} = {047A9723-9AAC-42E3-8C69-B3835F15FF96}
{A11C0DF2-1E13-4EED-BA49-44A57136B189} = {E2BD7D4D-9ED5-41CD-8401-C3FB26F203BB}
{6463FB13-5F01-4A1D-8B62-A454FB3812EB} = {E2BD7D4D-9ED5-41CD-8401-C3FB26F203BB}
EndGlobalSection