mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Update Core
This commit is contained in:
@@ -113,7 +113,6 @@ namespace SqlSugar
|
||||
{
|
||||
this.Context.Ado.CheckConnection();
|
||||
string sql = this.CheckSystemTablePermissionsSql;
|
||||
this.Context.Ado.CheckConnection();
|
||||
try
|
||||
{
|
||||
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
||||
|
@@ -18,6 +18,7 @@ namespace SqlSugar
|
||||
public IDbBind Bind { get { return this.Db.DbBind; } }
|
||||
public ISqlBuilder SqlBuilder { get; set; }
|
||||
public MappingTableList OldMappingTableList { get; set; }
|
||||
public MappingTableList QueryableMappingTableList { get; set; }
|
||||
public bool IsAs { get; set; }
|
||||
public QueryBuilder QueryBuilder
|
||||
{
|
||||
@@ -45,6 +46,7 @@ namespace SqlSugar
|
||||
OldMappingTableList = this.Context.MappingTables;
|
||||
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables);
|
||||
this.Context.MappingTables.Add(entityName, tableName);
|
||||
this.QueryableMappingTableList = this.Context.MappingTables;
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> AS(string tableName)
|
||||
@@ -54,6 +56,7 @@ namespace SqlSugar
|
||||
OldMappingTableList = this.Context.MappingTables;
|
||||
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables);
|
||||
this.Context.MappingTables.Add(entityName, tableName);
|
||||
this.QueryableMappingTableList = this.Context.MappingTables;
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<T> With(string withString)
|
||||
@@ -374,7 +377,7 @@ namespace SqlSugar
|
||||
{
|
||||
return _Select<TResult>(expression);
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> Select<TResult>(string selectValue) where TResult : class, new()
|
||||
public virtual ISugarQueryable<TResult> Select<TResult>(string selectValue)
|
||||
{
|
||||
var reval = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
|
||||
reval.Context = this.Context;
|
||||
@@ -390,7 +393,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual int Count()
|
||||
{
|
||||
|
||||
InitMapping();
|
||||
var sql = string.Empty;
|
||||
if (QueryBuilder.PartitionByValue.IsValuable())
|
||||
{
|
||||
@@ -467,6 +470,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual DataTable ToDataTable()
|
||||
{
|
||||
InitMapping();
|
||||
var sqlObj = this.ToSql();
|
||||
RestoreMapping();
|
||||
var result = this.Db.GetDataTable(sqlObj.Key, sqlObj.Value.ToArray());
|
||||
@@ -499,6 +503,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual List<T> ToList()
|
||||
{
|
||||
InitMapping();
|
||||
return _ToList<T>();
|
||||
}
|
||||
public virtual List<T> ToPageList(int pageIndex, int pageSize)
|
||||
@@ -532,6 +537,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
InitMapping();
|
||||
string sql = QueryBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
|
||||
@@ -676,6 +682,7 @@ namespace SqlSugar
|
||||
return this.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.DbColumnName).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
protected void RestoreMapping()
|
||||
{
|
||||
if (IsAs && _RestoreMapping)
|
||||
@@ -683,6 +690,11 @@ namespace SqlSugar
|
||||
this.Context.MappingTables = OldMappingTableList == null ? new MappingTableList() : OldMappingTableList;
|
||||
}
|
||||
}
|
||||
protected void InitMapping()
|
||||
{
|
||||
if (this.QueryableMappingTableList != null)
|
||||
this.Context.MappingTables = this.QueryableMappingTableList;
|
||||
}
|
||||
|
||||
private void SetContextModel<TResult>(List<TResult> result, Type entityType)
|
||||
{
|
||||
|
@@ -179,7 +179,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string GetAsString(string asName, string fieldValue)
|
||||
{
|
||||
if (fieldValue.Contains(".*") || fieldValue == "*") return fieldValue;
|
||||
if (fieldValue.Contains(".*")|| fieldValue=="*") return fieldValue;
|
||||
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldValue), "AS", GetTranslationColumnName(asName));
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ namespace SqlSugar
|
||||
bool Any();
|
||||
|
||||
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
|
||||
ISugarQueryable<TResult> Select<TResult>(string select) where TResult : class, new();
|
||||
ISugarQueryable<TResult> Select<TResult>(string select);
|
||||
ISugarQueryable<T> Select(string select);
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>sqlSugarCore</id>
|
||||
<version>4.2.1.8</version>
|
||||
<version>4.2.1.9</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>Landa</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user