mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Update Core
This commit is contained in:
@@ -166,7 +166,11 @@ namespace SqlSugar
|
||||
public IDeleteable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
|
||||
DeleteBuilder.WhereInfos.Add(expResult.GetResultString());
|
||||
var whereString = expResult.GetResultString();
|
||||
if (expression.ToString().Contains("Subqueryable()")){
|
||||
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".",this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
|
||||
}
|
||||
DeleteBuilder.WhereInfos.Add(whereString);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -184,6 +184,12 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> InsertColumns(string[] columns)
|
||||
{
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => columns.Any(ig => ig.Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase))).ToList();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod)
|
||||
{
|
||||
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => insertColumMethod(it.PropertyName)).ToList();
|
||||
|
@@ -75,6 +75,10 @@ namespace SqlSugar
|
||||
|
||||
public virtual string GetNoTranslationColumnName(string name)
|
||||
{
|
||||
if (name.Contains("="))
|
||||
{
|
||||
name=name.Split('=').First();
|
||||
}
|
||||
if (!name.Contains(SqlTranslationLeft)) return name;
|
||||
return name == null ? string.Empty : Regex.Match(name, @".*" + "\\" + SqlTranslationLeft + "(.*?)" + "\\" + SqlTranslationRight + "").Groups[1].Value;
|
||||
}
|
||||
|
@@ -274,7 +274,12 @@ namespace SqlSugar
|
||||
public IUpdateable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
var expResult = UpdateBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
|
||||
UpdateBuilder.WhereValues.Add(expResult.GetResultString());
|
||||
var whereString = expResult.GetResultString();
|
||||
if (expression.ToString().Contains("Subqueryable()"))
|
||||
{
|
||||
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
|
||||
}
|
||||
UpdateBuilder.WhereValues.Add(whereString);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -36,6 +36,10 @@ namespace SqlSugar
|
||||
{
|
||||
leftExpression = (leftExpression as UnaryExpression).Operand;
|
||||
}
|
||||
if (leftExpression is UnaryExpression && (leftExpression as UnaryExpression).Operand.Type == UtilConstants.BoolType && (leftExpression as UnaryExpression).NodeType != ExpressionType.Not&&rightExpression.Type==UtilConstants.BoolTypeNull)
|
||||
{
|
||||
leftExpression = (leftExpression as UnaryExpression).Operand;
|
||||
}
|
||||
if (rightExpression is UnaryExpression&& (rightExpression as UnaryExpression).Operand.Type==UtilConstants.BoolType&& (rightExpression as UnaryExpression).NodeType != ExpressionType.Not)
|
||||
{
|
||||
rightExpression = (rightExpression as UnaryExpression).Operand;
|
||||
|
@@ -59,7 +59,7 @@ namespace SqlSugar
|
||||
{
|
||||
CaseWhenResolve caseResole = new CaseWhenResolve(express, this.Context, parameter.OppsiteExpression);
|
||||
var appendSql = caseResole.GetSql();
|
||||
if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle))
|
||||
if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle,ResolveExpressType.Update))
|
||||
{
|
||||
parameter.BaseParameter.CommonTempData = appendSql;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ namespace SqlSugar
|
||||
IInsertable<T> AS(string tableName);
|
||||
IInsertable<T> With(string lockString);
|
||||
IInsertable<T> InsertColumns(Expression<Func<T, object>> columns);
|
||||
IInsertable<T> InsertColumns(string[] columns);
|
||||
IInsertable<T> InsertColumns(Func<string, bool> insertColumMethod);
|
||||
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
|
||||
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
|
||||
|
@@ -19,6 +19,7 @@ namespace SqlSugar
|
||||
internal static Type LongType = typeof(long);
|
||||
internal static Type GuidType = typeof(Guid);
|
||||
internal static Type BoolType = typeof(bool);
|
||||
internal static Type BoolTypeNull = typeof(bool?);
|
||||
internal static Type ByteType = typeof(Byte);
|
||||
internal static Type ObjType = typeof(object);
|
||||
internal static Type DobType = typeof(double);
|
||||
|
Reference in New Issue
Block a user