mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 04:53:45 +08:00
Update Core
This commit is contained in:
@@ -80,6 +80,7 @@ namespace SqlSugar
|
|||||||
#region Check
|
#region Check
|
||||||
public virtual bool IsAnyTable(string tableName, bool isCache = true)
|
public virtual bool IsAnyTable(string tableName, bool isCache = true)
|
||||||
{
|
{
|
||||||
|
Check.Exception(string.IsNullOrEmpty(tableName), "IsAnyTable tableName is not null");
|
||||||
tableName = this.SqlBuilder.GetNoTranslationColumnName(tableName);
|
tableName = this.SqlBuilder.GetNoTranslationColumnName(tableName);
|
||||||
var tables = GetTableInfoList(isCache);
|
var tables = GetTableInfoList(isCache);
|
||||||
if (tables == null) return false;
|
if (tables == null) return false;
|
||||||
|
@@ -216,7 +216,8 @@ namespace SqlSugar
|
|||||||
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
|
||||||
{
|
{
|
||||||
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
||||||
if (resolveType.IsIn(ResolveExpressType.FieldSingle,ResolveExpressType.FieldMultiple,ResolveExpressType.SelectSingle, ResolveExpressType.SelectMultiple) &&(expression is LambdaExpression)&& (expression as LambdaExpression).Body is BinaryExpression) {
|
if (resolveType.IsIn(ResolveExpressType.FieldSingle, ResolveExpressType.FieldMultiple, ResolveExpressType.SelectSingle, ResolveExpressType.SelectMultiple) && (expression is LambdaExpression) && (expression as LambdaExpression).Body is BinaryExpression)
|
||||||
|
{
|
||||||
resolveType = resolveType.IsIn(ResolveExpressType.SelectSingle, ResolveExpressType.FieldSingle) ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
|
resolveType = resolveType.IsIn(ResolveExpressType.SelectSingle, ResolveExpressType.FieldSingle) ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
|
||||||
}
|
}
|
||||||
this.LambdaExpressions.Clear();
|
this.LambdaExpressions.Clear();
|
||||||
@@ -246,7 +247,8 @@ namespace SqlSugar
|
|||||||
this.Parameters.AddRange(resolveExpress.Parameters);
|
this.Parameters.AddRange(resolveExpress.Parameters);
|
||||||
var result = resolveExpress.Result;
|
var result = resolveExpress.Result;
|
||||||
var isSingleTableHasSubquery = IsSingle() && resolveExpress.SingleTableNameSubqueryShortName.HasValue();
|
var isSingleTableHasSubquery = IsSingle() && resolveExpress.SingleTableNameSubqueryShortName.HasValue();
|
||||||
if (isSingleTableHasSubquery) {
|
if (isSingleTableHasSubquery)
|
||||||
|
{
|
||||||
Check.Exception(!string.IsNullOrEmpty(this.TableShortName) && resolveExpress.SingleTableNameSubqueryShortName != this.TableShortName, "{0} and {1} need same name");
|
Check.Exception(!string.IsNullOrEmpty(this.TableShortName) && resolveExpress.SingleTableNameSubqueryShortName != this.TableShortName, "{0} and {1} need same name");
|
||||||
this.TableShortName = resolveExpress.SingleTableNameSubqueryShortName;
|
this.TableShortName = resolveExpress.SingleTableNameSubqueryShortName;
|
||||||
}
|
}
|
||||||
@@ -550,7 +552,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var jsoinParameters = (this.JoinExpression as LambdaExpression).Parameters;
|
var jsoinParameters = (this.JoinExpression as LambdaExpression).Parameters;
|
||||||
var currentParametres = (expression as LambdaExpression).Parameters;
|
var currentParametres = (expression as LambdaExpression).Parameters;
|
||||||
if ((expression as LambdaExpression).Body.ToString() == "True") {
|
if ((expression as LambdaExpression).Body.ToString() == "True")
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentParametres != null && currentParametres.Count > 0)
|
if (currentParametres != null && currentParametres.Count > 0)
|
||||||
|
@@ -133,7 +133,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
// fetch the root object reference:
|
// fetch the root object reference:
|
||||||
var constExpr = expression as ConstantExpression;
|
var constExpr = expression as ConstantExpression;
|
||||||
if (constExpr == null) {
|
if (constExpr == null)
|
||||||
|
{
|
||||||
return DynamicInvoke(rootExpression);
|
return DynamicInvoke(rootExpression);
|
||||||
}
|
}
|
||||||
object objReference = constExpr.Value;
|
object objReference = constExpr.Value;
|
||||||
|
@@ -536,6 +536,37 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return this.DeserializeObject<List<T>>(this.SerializeObject(deserializeObject));
|
return this.DeserializeObject<List<T>>(this.SerializeObject(deserializeObject));
|
||||||
}
|
}
|
||||||
|
public DataTable ListToDataTable<T>(List<T> list)
|
||||||
|
{
|
||||||
|
DataTable result = new DataTable();
|
||||||
|
if (list.Count > 0)
|
||||||
|
{
|
||||||
|
PropertyInfo[] propertys = list[0].GetType().GetProperties();
|
||||||
|
foreach (PropertyInfo pi in propertys)
|
||||||
|
{
|
||||||
|
//获取类型
|
||||||
|
Type colType = pi.PropertyType;
|
||||||
|
//当类型为Nullable<>时
|
||||||
|
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
|
||||||
|
{
|
||||||
|
colType = colType.GetGenericArguments()[0];
|
||||||
|
}
|
||||||
|
result.Columns.Add(pi.Name, colType);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
ArrayList tempList = new ArrayList();
|
||||||
|
foreach (PropertyInfo pi in propertys)
|
||||||
|
{
|
||||||
|
object obj = pi.GetValue(list[i], null);
|
||||||
|
tempList.Add(obj);
|
||||||
|
}
|
||||||
|
object[] array = tempList.ToArray();
|
||||||
|
result.LoadDataRow(array, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public Dictionary<string, object> DataTableToDictionary(DataTable table)
|
public Dictionary<string, object> DataTableToDictionary(DataTable table)
|
||||||
{
|
{
|
||||||
return table.Rows.Cast<DataRow>().ToDictionary(x => x[0].ToString(), x => x[1]);
|
return table.Rows.Cast<DataRow>().ToDictionary(x => x[0].ToString(), x => x[1]);
|
||||||
|
@@ -27,6 +27,7 @@ namespace SqlSugar
|
|||||||
SqlSugarProvider CopyContext(bool isCopyEvents = false);
|
SqlSugarProvider CopyContext(bool isCopyEvents = false);
|
||||||
dynamic DataTableToDynamic(DataTable table);
|
dynamic DataTableToDynamic(DataTable table);
|
||||||
List<T> DataTableToList<T>(DataTable table);
|
List<T> DataTableToList<T>(DataTable table);
|
||||||
|
DataTable ListToDataTable<T>(List<T> list);
|
||||||
Dictionary<string, object> DataTableToDictionary(DataTable table);
|
Dictionary<string, object> DataTableToDictionary(DataTable table);
|
||||||
ICacheService GetReflectionInoCacheInstance();
|
ICacheService GetReflectionInoCacheInstance();
|
||||||
void RemoveCacheAll();
|
void RemoveCacheAll();
|
||||||
|
@@ -108,6 +108,7 @@ namespace SqlSugar
|
|||||||
new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("nchar",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("nchar",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("clob",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("clob",CSharpDataType.@string),
|
||||||
|
new KeyValuePair<string, CSharpDataType>("text",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("long",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("long",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("nclob",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("nclob",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("rowid",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("rowid",CSharpDataType.@string),
|
||||||
|
@@ -426,7 +426,7 @@ namespace SqlSugar
|
|||||||
var comments = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
var comments = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
string sql = "SELECT TVNAME AS TableName, COLNAME,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName.ToUpper() + "' ORDER BY TVNAME";
|
string sql = "SELECT TVNAME AS TableName, COLNAME as DbColumnName ,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName.ToUpper() + "' ORDER BY TVNAME";
|
||||||
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
||||||
this.Context.Ado.IsEnableLogEvent = false;
|
this.Context.Ado.IsEnableLogEvent = false;
|
||||||
var pks = this.Context.Ado.SqlQuery<DbColumnInfo>(sql);
|
var pks = this.Context.Ado.SqlQuery<DbColumnInfo>(sql);
|
||||||
|
@@ -99,7 +99,7 @@ namespace SqlSugar
|
|||||||
sqlParameter.DbType = parameter.DbType;
|
sqlParameter.DbType = parameter.DbType;
|
||||||
if (parameter.Direction == 0)
|
if (parameter.Direction == 0)
|
||||||
{
|
{
|
||||||
parameter.Direction= ParameterDirection.Input; ;
|
parameter.Direction = ParameterDirection.Input;
|
||||||
}
|
}
|
||||||
sqlParameter.Direction = parameter.Direction;
|
sqlParameter.Direction = parameter.Direction;
|
||||||
//if (sqlParameter.Direction == 0)
|
//if (sqlParameter.Direction == 0)
|
||||||
|
@@ -230,7 +230,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
return "alter table {0} rename to {1}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user