using Monitor.FrameWork;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DbType = SqlSugar.DbType;
|
|
|
|
namespace Aborlen.Model
|
|
{
|
|
public partial class BasicEntity<T> where T : class, new()
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 查询数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<T> Query(Expression<Func<T, bool>> whereAct)
|
|
{
|
|
using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = UserConfiguration.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }))
|
|
{
|
|
|
|
return db.Queryable<T>().Where(whereAct).ToList();
|
|
}
|
|
|
|
}
|
|
|
|
public static object Query(object whereAct)
|
|
{
|
|
return Query((Expression<Func<T, bool>>)whereAct);
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 查询所有数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<T> QueryAll()
|
|
{
|
|
using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = UserConfiguration.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }))
|
|
{
|
|
return db.Queryable<T>().ToList();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询数据 返回表达式
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static ISugarQueryable<T> Query()
|
|
{
|
|
using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = UserConfiguration.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }))
|
|
{
|
|
return db.Queryable<T>();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="topCount"></param>
|
|
/// <param name="skip"></param>
|
|
/// <returns></returns>
|
|
public static List<T> QueryTop(int topCount,int skip , Expression<Func<T, bool>> whereAct,string orderbyCol)
|
|
{
|
|
using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = UserConfiguration.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }))
|
|
{
|
|
return db.Queryable<T>().Where(whereAct).OrderBy(orderbyCol).Skip(skip).Take(topCount).ToList();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|