This commit is contained in:
sunkaixuan
2017-05-19 11:20:07 +08:00
parent abbb367442
commit d02fa4a26b
13 changed files with 36 additions and 36 deletions

View File

@@ -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);
};

View File

@@ -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);
};

View File

@@ -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)
{