mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Update mongodb
This commit is contained in:
@@ -112,7 +112,8 @@ namespace MongoDb.Ado.data
|
|||||||
throw new InvalidOperationException("No current document.");
|
throw new InvalidOperationException("No current document.");
|
||||||
|
|
||||||
var element = GetElementByOrdinal(ordinal);
|
var element = GetElementByOrdinal(ordinal);
|
||||||
return BsonTypeMapper.MapToDotNetValue(element.Value);
|
var result= BsonTypeMapper.MapToDotNetValue(element.Value);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
private BsonElement GetElementByOrdinal(int ordinal)
|
private BsonElement GetElementByOrdinal(int ordinal)
|
||||||
{
|
{
|
||||||
|
@@ -32,6 +32,8 @@ namespace MongoDbTest
|
|||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
var list = db.Queryable<OrderInfo>().ToList();
|
||||||
|
|
||||||
//测试生成SQL性能
|
//测试生成SQL性能
|
||||||
TestSqlBuilder(db);
|
TestSqlBuilder(db);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SqlSugar.MongoDb
|
namespace SqlSugar.MongoDb
|
||||||
@@ -46,42 +48,14 @@ namespace SqlSugar.MongoDb
|
|||||||
}
|
}
|
||||||
public override string ToSqlString()
|
public override string ToSqlString()
|
||||||
{
|
{
|
||||||
base.AppendFilter();
|
List<string> operations = new List<string>();
|
||||||
string oldOrderValue = this.OrderByValue;
|
var sb = new StringBuilder();
|
||||||
string result = null;
|
sb.Append($"aggregate {this.GetTableNameString} ");
|
||||||
sql = new StringBuilder();
|
sb.Append("[");
|
||||||
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString);
|
sb.Append(string.Join(", ", operations));
|
||||||
if (IsCount) { return sql.ToString(); }
|
sb.Append("]");
|
||||||
if (Skip != null && Take == null)
|
|
||||||
{
|
return sb.ToString();
|
||||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
|
||||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue);
|
|
||||||
}
|
|
||||||
else if (Skip == null && Take != null)
|
|
||||||
{
|
|
||||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
|
||||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
|
|
||||||
}
|
|
||||||
else if (Skip != null && Take != null)
|
|
||||||
{
|
|
||||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
|
||||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = sql.ToString();
|
|
||||||
}
|
|
||||||
this.OrderByValue = oldOrderValue;
|
|
||||||
result = GetSqlQuerySql(result);
|
|
||||||
if (result.IndexOf("-- No table") > 0)
|
|
||||||
{
|
|
||||||
return "-- No table";
|
|
||||||
}
|
|
||||||
if (TranLock != null)
|
|
||||||
{
|
|
||||||
result = result + TranLock;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Reference in New Issue
Block a user