merge
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Dapper;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Mapster;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
@@ -40,13 +41,6 @@ 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);
|
||||
@@ -78,5 +72,16 @@ namespace Ewide.Core.Extension
|
||||
commandType: commandType
|
||||
);
|
||||
}
|
||||
|
||||
private static string PageSqlBuilder(string sql , PageInputBase input)
|
||||
{
|
||||
var sqlStrList = new List<string>();
|
||||
var orderStr = OrderBuilder(input);
|
||||
if (!string.IsNullOrEmpty(orderStr)) sqlStrList.Add(" ORDER BY " + orderStr);
|
||||
// input.PageSize = 0表示不分页
|
||||
if (input.PageSize != 0) sqlStrList.Add(" LIMIT " + ((input.PageNo - 1) * input.PageSize).ToString() + "," + input.PageSize.ToString());
|
||||
sql += String.Join("", sqlStrList);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user