mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
More Settings
This commit is contained in:
@@ -439,6 +439,7 @@ namespace SqlSugar
|
||||
{
|
||||
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Queryable.Select Method .");
|
||||
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(), "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
|
||||
ToSqlBefore();
|
||||
var sql = QueryBuilder.ToSqlString();
|
||||
var tableName = this.SqlBuilder.GetPackTable(sql, "MergeTable");
|
||||
var mergeQueryable = this.Context.Queryable<ExpandoObject>();
|
||||
@@ -607,6 +608,7 @@ namespace SqlSugar
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
InitMapping();
|
||||
ToSqlBefore();
|
||||
string sql = QueryBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||
@@ -1059,12 +1061,21 @@ namespace SqlSugar
|
||||
protected int GetCount()
|
||||
{
|
||||
var sql = string.Empty;
|
||||
ToSqlBefore();
|
||||
sql = QueryBuilder.ToSqlString();
|
||||
sql = QueryBuilder.ToCountSql(sql);
|
||||
var reval = Context.Ado.GetInt(sql, QueryBuilder.Parameters.ToArray());
|
||||
return reval;
|
||||
}
|
||||
|
||||
private void ToSqlBefore()
|
||||
{
|
||||
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
||||
if (moreSetts != null && moreSetts.IsWithNoLockQuery&&string.IsNullOrEmpty(QueryBuilder.TableWithString)) {
|
||||
this.With(SqlWith.NoLock);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<TResult> GetData<TResult>(KeyValuePair<string, List<SugarParameter>> sqlObj)
|
||||
{
|
||||
List<TResult> result;
|
||||
|
13
Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs
Normal file
13
Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class ConnMoreSettings
|
||||
{
|
||||
public bool IsAutoRemoveDataCache { get; set; }
|
||||
public bool IsWithNoLockQuery { get; set; }
|
||||
}
|
||||
}
|
@@ -39,6 +39,10 @@ namespace SqlSugar
|
||||
/// All operations within a transaction is ConnectionString
|
||||
/// </summary>
|
||||
public List<SlaveConnectionConfig> SlaveConnectionConfigs { get; set; }
|
||||
/// <summary>
|
||||
/// More Gobal Settings
|
||||
/// </summary>
|
||||
public ConnMoreSettings MoreSettings { get; set; }
|
||||
}
|
||||
|
||||
public class ConfigureExternalServices
|
||||
|
@@ -77,6 +77,7 @@
|
||||
<Compile Include="CacheScheme\CacheSchemeMain.cs" />
|
||||
<Compile Include="Entities\CacheKey.cs" />
|
||||
<Compile Include="Entities\ConditionalModel.cs" />
|
||||
<Compile Include="Entities\ConnMoreSettings.cs" />
|
||||
<Compile Include="Entities\SlaveConnectionConfig.cs" />
|
||||
<Compile Include="Enum\ConditionalType.cs" />
|
||||
<Compile Include="Enum\DbType.cs" />
|
||||
|
Reference in New Issue
Block a user