update 解决dapper结果无法转为小写的问题

This commit is contained in:
2021-05-20 15:26:28 +08:00
parent 6cbb663e97
commit 4ec43c220e
3 changed files with 43 additions and 31 deletions

View File

@@ -1,15 +1,11 @@
using System;
using Dapper;
using Furion.DatabaseAccessor;
using Mapster;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Mapster;
namespace Ewide.Core.Extension
{
@@ -44,6 +40,13 @@ namespace Ewide.Core.Extension
return orderStr;
}
private static string PageSqlBuilder(string sql, PageInputBase input)
{
var orderStr = OrderBuilder(input);
var r = "SELECT * FROM (" + sql + ") T " + (string.IsNullOrEmpty(orderStr) ? string.Empty : "ORDER BY " + orderStr) + " LIMIT " + ((input.PageNo - 1) * input.PageSize).ToString() + "," + input.PageSize.ToString();
return r;
}
public static Task<PagedList<T>> ToPageData<T>(this IQueryable<T> source, PageInputBase input) where T : new()
{
return source.OrderBy(OrderBuilder<T>(input)).ToPagedListAsync(input.PageNo, input.PageSize);
@@ -54,31 +57,26 @@ namespace Ewide.Core.Extension
return source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>()).ToPagedListAsync(input.PageNo, input.PageSize);
}
public static Task<IEnumerable<dynamic>> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null)
public static Task<IEnumerable<dynamic>> QueryPageData(this IDapperRepository source, string sql, PageInputBase input, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return source.QueryAsync(PageSqlBuild(sql,input),
return source.QueryAsync(
PageSqlBuilder(sql, input),
param: param,
transaction: transaction,
commandTimeout: commandTimeout,
commandType: commandType
);
}
public static Task<IEnumerable<T>> QueryPageData<T>(this IDapperRepository source, string sql, PageInputBase input, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
{
return source.QueryAsync<T>(
PageSqlBuilder(sql, input),
param: param,
transaction: transaction,
commandTimeout: commandTimeout,
commandType: commandType
);
}
public static Task<IEnumerable<T>> QueryPageData<T>(this IDapperRepository source, string sql, PageInputBase input, object param = null, System.Data.IDbTransaction transaction = null, int? commandTimeout = null, System.Data.CommandType? commandType = null)
{
return source.QueryAsync<T>(sql,
param: param,
transaction: transaction,
commandTimeout: commandTimeout,
commandType: commandType
);
}
private static string PageSqlBuild(string sql , PageInputBase input)
{
var orderStr = OrderBuilder(input);
var r = "SELECT * FROM (" + sql + ") T " + (string.IsNullOrEmpty(orderStr) ? string.Empty : "Order by " + orderStr) + " LIMIT " + ((input.PageNo - 1) * input.PageSize).ToString() + "," + input.PageSize.ToString();
return r;
}
}
}