Browse Source

More Settings

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
21b39d7756
  1. 11
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 13
      Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs
  3. 4
      Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs
  4. 1
      Src/Asp.Net/SqlSugar/SqlSugar.csproj

11
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

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

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

4
Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs

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

1
Src/Asp.Net/SqlSugar/SqlSugar.csproj

@ -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" />

Loading…
Cancel
Save