mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-01 19:03:58 +08:00
-
This commit is contained in:
@@ -72,8 +72,8 @@ namespace OrmTest.UnitTest
|
||||
public SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
||||
db.Database.IsEnableLogEvent = true;
|
||||
db.Database.LogEventStarting = (sql, pars) =>
|
||||
db.Ado.IsEnableLogEvent = true;
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + " " + pars);
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OrmTest.UnitTest
|
||||
using (var db = GetInstance())
|
||||
{
|
||||
//db.Database.IsEnableLogEvent = true;
|
||||
db.Database.LogEventStarting = (sql, pars) =>
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + " " + pars);
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OrmTest.UnitTest
|
||||
SELECT * FROM (SELECT *,ROW_NUMBER() OVER(ORDER BY [Id] DESC) AS RowIndex FROM PageTable ) T WHERE RowIndex BETWEEN 11 AND 20", null, s6.Key, null, "s6 Error");
|
||||
|
||||
|
||||
int studentCount=db.Database.GetInt("select count(1) from Student");
|
||||
int studentCount=db.Ado.GetInt("select count(1) from Student");
|
||||
var countIsSuccess=db.Queryable<Student>().Count()== studentCount;
|
||||
if (!countIsSuccess) {
|
||||
throw new Exception("countIsSuccess Error");
|
||||
@@ -72,28 +72,28 @@ namespace OrmTest.UnitTest
|
||||
throw new Exception("s7 Error");
|
||||
}
|
||||
|
||||
int studentMin = db.Database.GetInt("select min(id) from Student");
|
||||
int studentMin = db.Ado.GetInt("select min(id) from Student");
|
||||
var minIsSuccess = db.Queryable<Student>().Min(it=>it.Id) == studentMin;
|
||||
if (!minIsSuccess)
|
||||
{
|
||||
throw new Exception("minIsSuccess Error");
|
||||
}
|
||||
|
||||
int studentMax = db.Database.GetInt("select max(id) from Student");
|
||||
int studentMax = db.Ado.GetInt("select max(id) from Student");
|
||||
var maxIsSuccess = db.Queryable<Student>().Max(it => it.Id) == studentMax;
|
||||
if (!maxIsSuccess)
|
||||
{
|
||||
throw new Exception("maxIsSuccess Error");
|
||||
}
|
||||
|
||||
int studentAvg = db.Database.GetInt("select avg(id) from Student");
|
||||
int studentAvg = db.Ado.GetInt("select avg(id) from Student");
|
||||
var avgIsSuccess = db.Queryable<Student>().Avg(it => it.Id) == studentAvg;
|
||||
if (!maxIsSuccess)
|
||||
{
|
||||
throw new Exception("avgIsSuccess Error");
|
||||
}
|
||||
|
||||
int studentSum = db.Database.GetInt("select sum(id) from Student");
|
||||
int studentSum = db.Ado.GetInt("select sum(id) from Student");
|
||||
var sumIsSuccess = db.Queryable<Student>().Sum(it => it.Id) == studentSum;
|
||||
if (!sumIsSuccess)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user