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