Browse Source

MySql Queryable.Take Bug

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
59e49827a5
  1. 1
      Src/Asp.Net/MySqlTest/Demos/1_Query.cs
  2. 2
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs
  3. 2
      Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteQueryBuilder.cs

1
Src/Asp.Net/MySqlTest/Demos/1_Query.cs

@ -153,6 +153,7 @@ namespace OrmTest.Demo
{ {
var db = GetInstance(); var db = GetInstance();
var getAll = db.Queryable<Student>().ToList(); var getAll = db.Queryable<Student>().ToList();
var getTop2 = db.Queryable<Student>().Take(2).ToList();//TOP2
var getLike = db.Queryable<Student>().Where(it => it.Name.Contains("a")).ToList(); var getLike = db.Queryable<Student>().Where(it => it.Name.Contains("a")).ToList();
var getAllOrder = db.Queryable<Student>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getAllOrder = db.Queryable<Student>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList();
var getId = db.Queryable<Student>().Select(it => it.Id).ToList(); var getId = db.Queryable<Student>().Select(it => it.Id).ToList();

2
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlQueryBuilder.cs

@ -48,7 +48,7 @@ namespace SqlSugar
else if (Skip == null && Take != null) else if (Skip == null && Take != null)
{ {
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0]; if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 1, Take.ObjToInt()); result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
} }
else if (Skip != null && Take != null) else if (Skip != null && Take != null)
{ {

2
Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteQueryBuilder.cs

@ -48,7 +48,7 @@ namespace SqlSugar
else if (Skip == null && Take != null) else if (Skip == null && Take != null)
{ {
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0]; if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
result= string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 1, Take.ObjToInt()); result= string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
} }
else if (Skip != null && Take != null) else if (Skip != null && Take != null)
{ {

Loading…
Cancel
Save