mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Update Core
This commit is contained in:
parent
ae0a67f89e
commit
3b535d7ff2
@ -304,7 +304,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
|
var name = GetType(propertyType.Name);
|
||||||
|
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +323,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
|
var name = GetType(propertyType.Name);
|
||||||
|
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(name);
|
||||||
}
|
}
|
||||||
var dataType = dc.DataType;
|
var dataType = dc.DataType;
|
||||||
if (properyTypeName == "boolean" && dataType == "bool")
|
if (properyTypeName == "boolean" && dataType == "bool")
|
||||||
@ -331,6 +333,16 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return properyTypeName != dataType;
|
return properyTypeName != dataType;
|
||||||
}
|
}
|
||||||
|
private static string GetType(string name)
|
||||||
|
{
|
||||||
|
if (name.IsContainsIn("UInt32", "UInt16", "UInt64"))
|
||||||
|
{
|
||||||
|
name = name.TrimStart('U');
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,7 @@ namespace SqlSugar
|
|||||||
result.InsertBuilder = this.InsertBuilder;
|
result.InsertBuilder = this.InsertBuilder;
|
||||||
result.Builder = this.SqlBuilder;
|
result.Builder = this.SqlBuilder;
|
||||||
result.Context = this.Context;
|
result.Context = this.Context;
|
||||||
|
result.Inserts=this.InsertObjs;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, TObject>> mapperObject, Expression<Func<T, object>> mapperField)
|
public virtual ISugarQueryable<T> Mapper<TObject>(Expression<Func<T, TObject>> mapperObject, Expression<Func<T, object>> mapperField)
|
||||||
{
|
{
|
||||||
|
if (CallContext.MapperExpression.Value == null)
|
||||||
|
{
|
||||||
|
CallContext.MapperExpression.Value = new List<MapperExpression>();
|
||||||
|
}
|
||||||
|
CallContext.MapperExpression.Value.Add(new MapperExpression() { SqlBuilder= SqlBuilder, QueryBuilder = this.QueryBuilder, Type=MapperExpressionType.oneToOne, FillExpression=mapperObject, MappingField1Expression= mapperField,Context=this.Context });
|
||||||
return _Mapper<TObject>(mapperObject, mapperField);
|
return _Mapper<TObject>(mapperObject, mapperField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ namespace SqlSugar
|
|||||||
public virtual string GetTranslationColumnName(string propertyName)
|
public virtual string GetTranslationColumnName(string propertyName)
|
||||||
{
|
{
|
||||||
if (propertyName.Contains(SqlTranslationLeft)) return propertyName;
|
if (propertyName.Contains(SqlTranslationLeft)) return propertyName;
|
||||||
|
if (propertyName.Contains("."))
|
||||||
|
{
|
||||||
|
return string.Join(".", propertyName.Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return SqlTranslationLeft + propertyName + SqlTranslationRight;
|
return SqlTranslationLeft + propertyName + SqlTranslationRight;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,10 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static void RemoveCache(ICacheService cacheService, string tableName)
|
public static void RemoveCache(ICacheService cacheService, string tableName)
|
||||||
{
|
{
|
||||||
|
if (cacheService == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
var keys = cacheService.GetAllKey<string>();
|
var keys = cacheService.GetAllKey<string>();
|
||||||
if (keys.HasValue())
|
if (keys.HasValue())
|
||||||
{
|
{
|
||||||
|
@ -251,13 +251,24 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static object DynamicInvoke(Expression expression, MemberExpression memberExpression = null)
|
public static object DynamicInvoke(Expression expression, MemberExpression memberExpression = null)
|
||||||
{
|
{
|
||||||
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
try
|
||||||
if (value != null && value.GetType().IsClass() && value.GetType() != UtilConstants.StringType && memberExpression != null)
|
|
||||||
{
|
{
|
||||||
value = Expression.Lambda(memberExpression).Compile().DynamicInvoke();
|
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
||||||
}
|
if (value != null && value.GetType().IsClass() && value.GetType() != UtilConstants.StringType && memberExpression != null)
|
||||||
|
{
|
||||||
|
value = Expression.Lambda(memberExpression).Compile().DynamicInvoke();
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return new MapperExpressionResolve(expression,ex).GetSql(); ;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("No support "+expression.ToString()+" "+ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type GetPropertyOrFieldType(MemberInfo propertyOrField)
|
public static Type GetPropertyOrFieldType(MemberInfo propertyOrField)
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class MapperExpression
|
||||||
|
{
|
||||||
|
public MapperExpressionType Type { get; set; }
|
||||||
|
public Expression FillExpression { get; set; }
|
||||||
|
public Expression MappingField1Expression { get; set; }
|
||||||
|
public Expression MappingField2Expression { get; set; }
|
||||||
|
public SqlSugarProvider Context { get; set; }
|
||||||
|
public QueryBuilder QueryBuilder { get; set; }
|
||||||
|
public ISqlBuilder SqlBuilder { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MapperExpressionType
|
||||||
|
{
|
||||||
|
oneToOne=1,
|
||||||
|
oneToN=2
|
||||||
|
}
|
||||||
|
}
|
@ -129,7 +129,7 @@ namespace SqlSugar
|
|||||||
if (this.Value != null)
|
if (this.Value != null)
|
||||||
this.Value = this.Value.ToString();
|
this.Value = this.Value.ToString();
|
||||||
}
|
}
|
||||||
else if (type.IsEnum())
|
else if (type!=null&&type.IsEnum())
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Int64;
|
this.DbType = System.Data.DbType.Int64;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int SubQueryIndex { get; set; }
|
public int SubQueryIndex { get; set; }
|
||||||
|
public int JoinIndex { get; set; }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
public int ParameterIndex { get; set; }
|
public int ParameterIndex { get; set; }
|
||||||
public string SingleTableNameSubqueryShortName{ get; set; }
|
public string SingleTableNameSubqueryShortName{ get; set; }
|
||||||
|
@ -133,7 +133,7 @@ namespace SqlSugar
|
|||||||
if (parameter.BaseExpression is BinaryExpression || parameter.BaseExpression == null)
|
if (parameter.BaseExpression is BinaryExpression || parameter.BaseExpression == null)
|
||||||
{
|
{
|
||||||
var oppoSiteExpression = isLeft == true ? parameter.BaseParameter.RightExpression : parameter.BaseParameter.LeftExpression;
|
var oppoSiteExpression = isLeft == true ? parameter.BaseParameter.RightExpression : parameter.BaseParameter.LeftExpression;
|
||||||
if (parameter.CurrentExpression is MethodCallExpression||parameter.CurrentExpression is ConditionalExpression||parameter.CurrentExpression.NodeType==ExpressionType.Coalesce)
|
if (parameter.CurrentExpression is MethodCallExpression || parameter.CurrentExpression is ConditionalExpression || parameter.CurrentExpression.NodeType == ExpressionType.Coalesce)
|
||||||
{
|
{
|
||||||
var appendValue = value;
|
var appendValue = value;
|
||||||
if (this.Context.Result.Contains(ExpressionConst.FormatSymbol))
|
if (this.Context.Result.Contains(ExpressionConst.FormatSymbol))
|
||||||
@ -146,6 +146,22 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
this.AppendOpreator(parameter, isLeft);
|
this.AppendOpreator(parameter, isLeft);
|
||||||
}
|
}
|
||||||
|
else if (value is MapperSql)
|
||||||
|
{
|
||||||
|
var sql = ((MapperSql)value).Sql;
|
||||||
|
if (isLeft == true)
|
||||||
|
{
|
||||||
|
sql += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index;
|
||||||
|
}
|
||||||
|
if (this.Context.Result.Contains(ExpressionConst.FormatSymbol))
|
||||||
|
{
|
||||||
|
this.Context.Result.Replace(ExpressionConst.FormatSymbol, sql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Context.Result.Append(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (oppoSiteExpression is MemberExpression)
|
else if (oppoSiteExpression is MemberExpression)
|
||||||
{
|
{
|
||||||
string appendValue = Context.SqlParameterKeyWord
|
string appendValue = Context.SqlParameterKeyWord
|
||||||
@ -174,7 +190,8 @@ namespace SqlSugar
|
|||||||
this.Context.Result.Append(appendValue);
|
this.Context.Result.Append(appendValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((oppoSiteExpression is UnaryExpression && (oppoSiteExpression as UnaryExpression).Operand is MemberExpression)) {
|
else if ((oppoSiteExpression is UnaryExpression && (oppoSiteExpression as UnaryExpression).Operand is MemberExpression))
|
||||||
|
{
|
||||||
string appendValue = Context.SqlParameterKeyWord
|
string appendValue = Context.SqlParameterKeyWord
|
||||||
+ ((MemberExpression)(oppoSiteExpression as UnaryExpression).Operand).Member.Name
|
+ ((MemberExpression)(oppoSiteExpression as UnaryExpression).Operand).Member.Name
|
||||||
+ Context.ParameterIndex;
|
+ Context.ParameterIndex;
|
||||||
|
@ -0,0 +1,224 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class MapperExpressionResolve
|
||||||
|
{
|
||||||
|
private Expression expression;
|
||||||
|
private List<MapperExpression> mappers;
|
||||||
|
private InvalidOperationException ex;
|
||||||
|
private SqlSugarProvider context;
|
||||||
|
private QueryBuilder querybuiler;
|
||||||
|
private ISqlBuilder sqlBuilder;
|
||||||
|
private string sql;
|
||||||
|
public MapperExpressionResolve(Expression expression, InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
this.expression = expression;
|
||||||
|
this.ex = ex;
|
||||||
|
this.mappers = CallContext.MapperExpression.Value;
|
||||||
|
Error01();
|
||||||
|
var isMember = expression is MemberExpression;
|
||||||
|
if (isMember)
|
||||||
|
{
|
||||||
|
ResolveMember();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ResolveList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResolveList()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResolveMember()
|
||||||
|
{
|
||||||
|
var exp = expression as MemberExpression;
|
||||||
|
ThrowTrue(exp.Expression == null);
|
||||||
|
var childExpression = exp.Expression;
|
||||||
|
MapperExpression mapper = GetMapper(exp);
|
||||||
|
var fillInfo=GetFillInfo(childExpression, mapper);
|
||||||
|
var mappingFild1Info = GetMappingFild1Info(childExpression, mapper);
|
||||||
|
var mappingFild1Info2 = GetMappingFild2Info(childExpression, mapper);
|
||||||
|
var SelectInfo = GetSelectInfo(expression);
|
||||||
|
var entity = this.context.EntityMaintenance.GetEntityInfo(childExpression.Type);
|
||||||
|
|
||||||
|
var isExMapper = mappingFild1Info2!=null;
|
||||||
|
var isFillFild1SameType = fillInfo.Type == mappingFild1Info.Type;
|
||||||
|
var isSameProperty = false;
|
||||||
|
|
||||||
|
if (isExMapper)
|
||||||
|
{
|
||||||
|
ExtMapper();
|
||||||
|
}
|
||||||
|
else if (isSameProperty)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isFillFild1SameType)
|
||||||
|
{
|
||||||
|
oneToMany();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oneToOne(fillInfo, mappingFild1Info, mappingFild1Info2,SelectInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void oneToOne(MapperExpressionInfo fillInfo, MapperExpressionInfo mappingFild1Info, MapperExpressionInfo mappingFild1Info2, MapperExpressionInfo selectInfo)
|
||||||
|
{
|
||||||
|
var pkColumn = selectInfo.EntityInfo.Columns.Where(it => it.IsPrimarykey == true).FirstOrDefault();
|
||||||
|
if (pkColumn == null)
|
||||||
|
{
|
||||||
|
pkColumn = selectInfo.EntityInfo.Columns.First();
|
||||||
|
}
|
||||||
|
var tableName = sqlBuilder.GetTranslationTableName(fillInfo.EntityInfo.DbTableName);
|
||||||
|
var whereLeft = sqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName);
|
||||||
|
var whereRight = sqlBuilder.GetTranslationColumnName(mappingFild1Info.FieldString);
|
||||||
|
this.sql = this.context.Queryable<object>()
|
||||||
|
.AS(tableName)
|
||||||
|
.Where(string.Format(" {0}={1} ",whereLeft , whereRight))
|
||||||
|
.Select(sqlBuilder.GetTranslationColumnName(selectInfo.FieldName)).ToSql().Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void oneToMany()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapperExpressionInfo GetSelectInfo(Expression expression)
|
||||||
|
{
|
||||||
|
|
||||||
|
var field = expression;
|
||||||
|
if (field is UnaryExpression)
|
||||||
|
{
|
||||||
|
field = (field as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
|
var type = ((field as MemberExpression).Expression).Type;
|
||||||
|
this.context.InitMappingInfo(type);
|
||||||
|
var name = (field as MemberExpression).Member.Name;
|
||||||
|
var entity = this.context.EntityMaintenance.GetEntityInfo(type);
|
||||||
|
var fieldName = entity.Columns.First(it => it.PropertyName == name).DbColumnName;
|
||||||
|
return new MapperExpressionInfo()
|
||||||
|
{
|
||||||
|
Type = type,
|
||||||
|
FieldName = fieldName,
|
||||||
|
EntityInfo= entity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapperExpressionInfo GetMappingFild2Info(Expression childExpression, MapperExpression mapper)
|
||||||
|
{
|
||||||
|
if (mapper.MappingField2Expression == null)
|
||||||
|
return null;
|
||||||
|
var exp = mapper.MappingField2Expression;
|
||||||
|
var field = (exp as LambdaExpression).Body;
|
||||||
|
if (field is UnaryExpression)
|
||||||
|
{
|
||||||
|
field = (field as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
|
var type = ((field as MemberExpression).Expression).Type;
|
||||||
|
this.context.InitMappingInfo(type);
|
||||||
|
var name = (field as MemberExpression).Member.Name;
|
||||||
|
var entity = this.context.EntityMaintenance.GetEntityInfo(type);
|
||||||
|
var fieldName = entity.Columns.First(it => it.PropertyName == name).DbColumnName;
|
||||||
|
return new MapperExpressionInfo()
|
||||||
|
{
|
||||||
|
Type = type,
|
||||||
|
FieldName = fieldName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapperExpressionInfo GetMappingFild1Info(Expression childExpression, MapperExpression mapper)
|
||||||
|
{
|
||||||
|
var exp = mapper.MappingField1Expression;
|
||||||
|
var field = (exp as LambdaExpression).Body;
|
||||||
|
if (field is UnaryExpression)
|
||||||
|
{
|
||||||
|
field = (field as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
|
var type = ((field as MemberExpression).Expression).Type;
|
||||||
|
this.context.InitMappingInfo(type);
|
||||||
|
var name =(field as MemberExpression).Member.Name;
|
||||||
|
var entity = this.context.EntityMaintenance.GetEntityInfo(type);
|
||||||
|
var fieldName=entity.Columns.First(it => it.PropertyName == name).DbColumnName;
|
||||||
|
var array = (field as MemberExpression).ToString().Split('.').ToList();
|
||||||
|
array[array.Count()-1] = fieldName;
|
||||||
|
var filedString = string.Join(".", array);
|
||||||
|
return new MapperExpressionInfo()
|
||||||
|
{
|
||||||
|
Type=type,
|
||||||
|
FieldName = fieldName,
|
||||||
|
FieldString= filedString,
|
||||||
|
EntityInfo= entity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapperExpressionInfo GetFillInfo(Expression childExpression, MapperExpression mapper)
|
||||||
|
{
|
||||||
|
this.querybuiler = mapper.QueryBuilder;
|
||||||
|
this.context = mapper.Context;
|
||||||
|
this.sqlBuilder = mapper.SqlBuilder;
|
||||||
|
if (this.querybuiler.TableShortName.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
this.querybuiler.TableShortName = (childExpression as MemberExpression).Expression.ToString();
|
||||||
|
}
|
||||||
|
this.context.InitMappingInfo(childExpression.Type);
|
||||||
|
return new MapperExpressionInfo() {
|
||||||
|
EntityInfo=this.context.EntityMaintenance.GetEntityInfo(childExpression.Type)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapperExpression GetMapper(MemberExpression exp)
|
||||||
|
{
|
||||||
|
var mapper= mappers.Where(it => it.Type == MapperExpressionType.oneToOne)
|
||||||
|
.Reverse()
|
||||||
|
.Where(it => (it.FillExpression as LambdaExpression).Body.ToString() == exp.Expression.ToString()).FirstOrDefault();
|
||||||
|
ThrowTrue(mapper == null);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetMemberName(MemberExpression memberExpression)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtMapper()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapperSql GetSql()
|
||||||
|
{
|
||||||
|
return new MapperSql() { Sql = " (" + this.sql + ") " };
|
||||||
|
}
|
||||||
|
|
||||||
|
void Error01()
|
||||||
|
{
|
||||||
|
Check.Exception(mappers == null, ErrorMessage.GetThrowMessage(expression.ToString() + "no support", "当前表达式" + expression.ToString() + "必须在Mapper之后使用"));
|
||||||
|
}
|
||||||
|
void ThrowTrue(bool isError)
|
||||||
|
{
|
||||||
|
Check.Exception(isError, ErrorMessage.GetThrowMessage(expression.ToString() + "no support", "不支持表达式" + expression.ToString()+ " 1.检查当前表达式中的别名是否与Mapper中的一致 2.目前只支持 1对1 Mapper下的 Where "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MapperSql
|
||||||
|
{
|
||||||
|
public string Sql { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MapperExpressionInfo
|
||||||
|
{
|
||||||
|
public Type Type { get; set; }
|
||||||
|
public EntityInfo EntityInfo { get; set; }
|
||||||
|
public string FieldName { get; set; }
|
||||||
|
public string FieldString { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class SubInnerJoin : ISubOperation
|
||||||
|
{
|
||||||
|
|
||||||
|
public bool HasWhere
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "InnerJoin"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression Expression
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Sort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 301;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpressionContext Context
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetValue(Expression expression)
|
||||||
|
{
|
||||||
|
var exp = expression as MethodCallExpression;
|
||||||
|
var argExp = exp.Arguments[0];
|
||||||
|
var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name);
|
||||||
|
var parameter = (argExp as LambdaExpression).Parameters[1];
|
||||||
|
Context.InitMappingInfo(parameter.Type);
|
||||||
|
var tableName= Context.GetTranslationTableName(parameter.Type.Name, true);
|
||||||
|
var joinString =string.Format(" {2} INNER JOIN {1} {0} ",
|
||||||
|
this.Context.GetTranslationColumnName(parameter.Name),
|
||||||
|
tableName,
|
||||||
|
this.Context.JoinIndex==0?name:"");
|
||||||
|
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||||
|
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||||
|
this.Context.JoinIndex++;
|
||||||
|
|
||||||
|
//result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class SubLeftJoin : ISubOperation
|
||||||
|
{
|
||||||
|
|
||||||
|
public bool HasWhere
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "LeftJoin"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expression Expression
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Sort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 301;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpressionContext Context
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetValue(Expression expression)
|
||||||
|
{
|
||||||
|
var exp = expression as MethodCallExpression;
|
||||||
|
var argExp = exp.Arguments[0];
|
||||||
|
var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name);
|
||||||
|
var parameter = (argExp as LambdaExpression).Parameters[1];
|
||||||
|
Context.InitMappingInfo(parameter.Type);
|
||||||
|
var tableName= Context.GetTranslationTableName(parameter.Type.Name, true);
|
||||||
|
var joinString =string.Format(" {2} LEFT JOIN {1} {0} ",
|
||||||
|
this.Context.GetTranslationColumnName(parameter.Name),
|
||||||
|
tableName,
|
||||||
|
this.Context.JoinIndex==0?name:"");
|
||||||
|
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||||
|
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||||
|
this.Context.JoinIndex++;
|
||||||
|
|
||||||
|
//result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class SubWhere: ISubOperation
|
public class SubWhere : ISubOperation
|
||||||
{
|
{
|
||||||
public bool HasWhere
|
public bool HasWhere
|
||||||
{
|
{
|
||||||
@ -34,14 +34,14 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public ExpressionContext Context
|
public ExpressionContext Context
|
||||||
{
|
{
|
||||||
get;set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetValue(Expression expression)
|
public string GetValue(Expression expression)
|
||||||
{
|
{
|
||||||
var exp = expression as MethodCallExpression;
|
var exp = expression as MethodCallExpression;
|
||||||
var argExp= exp.Arguments[0];
|
var argExp = exp.Arguments[0];
|
||||||
var result= "WHERE "+SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
var result = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||||
|
|
||||||
|
|
||||||
var regex = @"^WHERE (\@Const\d+) $";
|
var regex = @"^WHERE (\@Const\d+) $";
|
||||||
@ -59,8 +59,9 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name)+UtilConstants.Dot;
|
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||||
result = result.Replace(selfParameterName,SubTools.GetSubReplace(this.Context));
|
if (this.Context.JoinIndex == 0)
|
||||||
|
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@ namespace SqlSugar
|
|||||||
var argExp = exp.Arguments[1];
|
var argExp = exp.Arguments[1];
|
||||||
var result = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); ;
|
var result = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); ;
|
||||||
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||||
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
if (this.Context.JoinIndex == 0)
|
||||||
|
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ namespace SqlSugar
|
|||||||
new SubSelect() { Context=Context },
|
new SubSelect() { Context=Context },
|
||||||
new SubWhere(){ Context=Context },
|
new SubWhere(){ Context=Context },
|
||||||
new SubWhereIF(){ Context=Context },
|
new SubWhereIF(){ Context=Context },
|
||||||
|
new SubLeftJoin(){ Context=Context },
|
||||||
|
new SubInnerJoin(){ Context=Context },
|
||||||
new SubAnd(){ Context=Context },
|
new SubAnd(){ Context=Context },
|
||||||
new SubAndIF(){ Context=Context },
|
new SubAndIF(){ Context=Context },
|
||||||
new SubAny(){ Context=Context },
|
new SubAny(){ Context=Context },
|
||||||
|
@ -9,6 +9,16 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public class Subqueryable<T> where T : class, new()
|
public class Subqueryable<T> where T : class, new()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public Subqueryable<T> InnerJoin<JoinType>(Func<T, JoinType, bool> expression)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public Subqueryable<T> LeftJoin<JoinType>(Func<T, JoinType, bool> expression)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Subqueryable<T> Where(string where)
|
public Subqueryable<T> Where(string where)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
|
@ -98,6 +98,9 @@ namespace SqlSugar
|
|||||||
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.@decimal),
|
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.@decimal),
|
||||||
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.Single),
|
new KeyValuePair<string, CSharpDataType>("decimal",CSharpDataType.Single),
|
||||||
|
|
||||||
|
new KeyValuePair<string, SqlSugar.CSharpDataType>("double precision",CSharpDataType.@double),
|
||||||
|
new KeyValuePair<string, SqlSugar.CSharpDataType>("binary", CSharpDataType.@byteArray),
|
||||||
|
|
||||||
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@string),
|
||||||
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@Guid),
|
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@Guid),
|
||||||
new KeyValuePair<string, CSharpDataType>("varchar2",CSharpDataType.@string),
|
new KeyValuePair<string, CSharpDataType>("varchar2",CSharpDataType.@string),
|
||||||
|
@ -433,7 +433,15 @@ namespace SqlSugar
|
|||||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||||
return pks;
|
return pks;
|
||||||
});
|
});
|
||||||
return comments.HasValue() ? comments.First(it => it.DbColumnName.Equals(filedName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : "";
|
if (comments.HasValue())
|
||||||
|
{
|
||||||
|
var comment = comments.FirstOrDefault(it => it.DbColumnName.Equals(filedName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
return comment?.ColumnDescription;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ namespace SqlSugar
|
|||||||
string sql = string.Format(this.RenameColumnSql, tableName, oldColumnName, newColumnName);
|
string sql = string.Format(this.RenameColumnSql, tableName, oldColumnName, newColumnName);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,19 @@ namespace SqlSugar
|
|||||||
internal SqlSugarProvider Context { get; set; }
|
internal SqlSugarProvider Context { get; set; }
|
||||||
internal ISqlBuilder Builder { get; set; }
|
internal ISqlBuilder Builder { get; set; }
|
||||||
internal InsertBuilder InsertBuilder { get; set; }
|
internal InsertBuilder InsertBuilder { get; set; }
|
||||||
|
internal object[] Inserts { get; set; }
|
||||||
|
|
||||||
public int ExecuteBlueCopy()
|
public int ExecuteBlueCopy()
|
||||||
{
|
{
|
||||||
if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
|
if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
|
||||||
|
|
||||||
DataTable dt;
|
if (Inserts.First().GetType() == typeof(DataTable))
|
||||||
SqlBulkCopy bulkCopy;
|
{
|
||||||
SetCopyData(out dt, out bulkCopy);
|
return WriteToServer();
|
||||||
|
}
|
||||||
|
DataTable dt = GetCopyData();
|
||||||
|
SqlBulkCopy bulkCopy = GetBulkCopyInstance();
|
||||||
|
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bulkCopy.WriteToServer(dt);
|
bulkCopy.WriteToServer(dt);
|
||||||
@ -30,19 +36,21 @@ namespace SqlSugar
|
|||||||
this.Context.Ado.Connection.Close();
|
this.Context.Ado.Connection.Close();
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Context.Ado.Transaction == null)
|
CloseDb();
|
||||||
{
|
|
||||||
this.Context.Ado.Connection.Close();
|
|
||||||
}
|
|
||||||
return DbColumnInfoList.Count;
|
return DbColumnInfoList.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ExecuteBlueCopyAsync()
|
public async Task<int> ExecuteBlueCopyAsync()
|
||||||
{
|
{
|
||||||
if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
|
if (DbColumnInfoList == null || DbColumnInfoList.Count == 0) return 0;
|
||||||
|
|
||||||
DataTable dt;
|
if (Inserts.First().GetType() == typeof(DataTable))
|
||||||
SqlBulkCopy bulkCopy;
|
{
|
||||||
SetCopyData(out dt, out bulkCopy);
|
return WriteToServer();
|
||||||
|
}
|
||||||
|
DataTable dt=GetCopyData();
|
||||||
|
SqlBulkCopy bulkCopy = GetBulkCopyInstance();
|
||||||
|
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await bulkCopy.WriteToServerAsync(dt);
|
await bulkCopy.WriteToServerAsync(dt);
|
||||||
@ -59,9 +67,62 @@ namespace SqlSugar
|
|||||||
return DbColumnInfoList.Count;
|
return DbColumnInfoList.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCopyData(out DataTable dt, out SqlBulkCopy bulkCopy)
|
private int WriteToServer()
|
||||||
{
|
{
|
||||||
dt = this.Context.Ado.GetDataTable("select top 0 * from " + InsertBuilder.GetTableNameString);
|
var dt = this.Inserts.First() as DataTable;
|
||||||
|
if (dt == null)
|
||||||
|
return 0;
|
||||||
|
Check.Exception(dt.TableName == "Table", "dt.TableName can't be null ");
|
||||||
|
dt = GetCopyWriteDataTable(dt);
|
||||||
|
SqlBulkCopy copy = GetBulkCopyInstance();
|
||||||
|
copy.DestinationTableName = this.Builder.GetTranslationColumnName(dt.TableName);
|
||||||
|
copy.WriteToServer(dt);
|
||||||
|
CloseDb();
|
||||||
|
return dt.Rows.Count;
|
||||||
|
}
|
||||||
|
private DataTable GetCopyWriteDataTable(DataTable dt)
|
||||||
|
{
|
||||||
|
var result = this.Context.Ado.GetDataTable("select top 0 * from " + this.Builder.GetTranslationColumnName(dt.TableName));
|
||||||
|
foreach (DataRow item in dt.Rows)
|
||||||
|
{
|
||||||
|
DataRow dr= result.NewRow();
|
||||||
|
foreach (DataColumn column in result.Columns)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (dt.Columns.Cast<DataColumn>().Select(it => it.ColumnName.ToLower()).Contains(column.ColumnName.ToLower()))
|
||||||
|
{
|
||||||
|
dr[column.ColumnName] = item[column.ColumnName];
|
||||||
|
if (dr[column.ColumnName] == null)
|
||||||
|
{
|
||||||
|
dr[column.ColumnName] = DBNull.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Rows.Add(dr);
|
||||||
|
}
|
||||||
|
result.TableName = dt.TableName;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
private SqlBulkCopy GetBulkCopyInstance()
|
||||||
|
{
|
||||||
|
SqlBulkCopy copy;
|
||||||
|
if (this.Context.Ado.Transaction == null)
|
||||||
|
{
|
||||||
|
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.CheckConstraints, (SqlTransaction)this.Context.Ado.Transaction);
|
||||||
|
}
|
||||||
|
if (this.Context.Ado.Connection.State == ConnectionState.Closed)
|
||||||
|
{
|
||||||
|
this.Context.Ado.Connection.Open();
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
private DataTable GetCopyData()
|
||||||
|
{
|
||||||
|
var dt = this.Context.Ado.GetDataTable("select top 0 * from " + InsertBuilder.GetTableNameString);
|
||||||
foreach (var rowInfos in DbColumnInfoList)
|
foreach (var rowInfos in DbColumnInfoList)
|
||||||
{
|
{
|
||||||
var dr = dt.NewRow();
|
var dr = dt.NewRow();
|
||||||
@ -81,35 +142,23 @@ namespace SqlSugar
|
|||||||
value.Value = Convert.ToDateTime("1753/01/01");
|
value.Value = Convert.ToDateTime("1753/01/01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (value.Value == null)
|
||||||
|
{
|
||||||
|
value.Value = DBNull.Value;
|
||||||
|
}
|
||||||
dr[item.ColumnName] = value.Value;
|
dr[item.ColumnName] = value.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dt.Rows.Add(dr);
|
dt.Rows.Add(dr);
|
||||||
}
|
}
|
||||||
bulkCopy = null;
|
return dt;
|
||||||
if (this.Context.Ado.Transaction != null)
|
|
||||||
{
|
|
||||||
var sqlTran = this.Context.Ado.Transaction as SqlTransaction;
|
|
||||||
bulkCopy = new SqlBulkCopy(this.Context.Ado.Connection as SqlConnection, SqlBulkCopyOptions.CheckConstraints, sqlTran);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bulkCopy = new SqlBulkCopy(this.Context.Ado.Connection as SqlConnection);
|
|
||||||
}
|
|
||||||
//获取目标表的名称
|
|
||||||
bulkCopy.DestinationTableName = InsertBuilder.GetTableNameString;
|
|
||||||
//写入DataReader对象
|
|
||||||
if (this.Context.Ado.Connection.State == ConnectionState.Closed)
|
|
||||||
{
|
|
||||||
this.Context.Ado.Connection.Open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
private void CloseDb()
|
||||||
private object AddParameter(int i,string dbColumnName, object value)
|
|
||||||
{
|
{
|
||||||
var name =Builder.SqlParameterKeyWord+dbColumnName+i;
|
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Context.Ado.Transaction == null)
|
||||||
InsertBuilder.Parameters.Add(new SugarParameter(name,value));
|
{
|
||||||
return name;
|
this.Context.Ado.Connection.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual async Task<bool> DeleteByIdAsync(dynamic id)
|
public virtual async Task<bool> DeleteByIdAsync(dynamic id)
|
||||||
{
|
{
|
||||||
return await this.Context.Deleteable<T>().In(id).ExecuteCommand() > 0;
|
return await this.Context.Deleteable<T>().In(id).ExecuteCommandAsync() > 0;
|
||||||
}
|
}
|
||||||
public virtual async Task<bool> DeleteByIdsAsync(dynamic[] ids)
|
public virtual async Task<bool> DeleteByIdsAsync(dynamic[] ids)
|
||||||
{
|
{
|
||||||
|
@ -553,6 +553,8 @@ namespace SqlSugar
|
|||||||
if (this._IsOpen)
|
if (this._IsOpen)
|
||||||
this.Open();
|
this.Open();
|
||||||
_Context.Ado.IsEnableLogEvent = isLog;
|
_Context.Ado.IsEnableLogEvent = isLog;
|
||||||
|
if (_CurrentConnectionConfig.AopEvents==null)
|
||||||
|
_CurrentConnectionConfig.AopEvents = new AopEvents();
|
||||||
}
|
}
|
||||||
public void ChangeDatabase(Func<ConnectionConfig, bool> changeExpression)
|
public void ChangeDatabase(Func<ConnectionConfig, bool> changeExpression)
|
||||||
{
|
{
|
||||||
@ -565,6 +567,8 @@ namespace SqlSugar
|
|||||||
if (this._IsOpen)
|
if (this._IsOpen)
|
||||||
this.Open();
|
this.Open();
|
||||||
_Context.Ado.IsEnableLogEvent = isLog;
|
_Context.Ado.IsEnableLogEvent = isLog;
|
||||||
|
if (_CurrentConnectionConfig.AopEvents == null)
|
||||||
|
_CurrentConnectionConfig.AopEvents = new AopEvents();
|
||||||
}
|
}
|
||||||
public void BeginTran()
|
public void BeginTran()
|
||||||
{
|
{
|
||||||
|
@ -11,5 +11,6 @@ namespace SqlSugar
|
|||||||
internal class CallContext
|
internal class CallContext
|
||||||
{
|
{
|
||||||
public static ThreadLocal<List<SqlSugarProvider>> ContextList = new ThreadLocal<List<SqlSugarProvider>>();
|
public static ThreadLocal<List<SqlSugarProvider>> ContextList = new ThreadLocal<List<SqlSugarProvider>>();
|
||||||
|
public static ThreadLocal<List<MapperExpression>> MapperExpression = new ThreadLocal<List<MapperExpression>>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,8 @@ namespace SqlSugar
|
|||||||
itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase);
|
itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase);
|
||||||
itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase);
|
itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase);
|
||||||
itemSql = Regex.Replace(itemSql, string.Format(@"\+{0}\+", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
|
itemSql = Regex.Replace(itemSql, string.Format(@"\+{0}\+", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
|
||||||
|
itemSql = Regex.Replace(itemSql, string.Format(@"\+{0} ", "\\" + itemParameter.ParameterName), "+" + newName +" ", RegexOptions.IgnoreCase);
|
||||||
|
itemSql = Regex.Replace(itemSql, string.Format(@" {0}\+", "\\" + itemParameter.ParameterName)," "+ newName + "+", RegexOptions.IgnoreCase);
|
||||||
itemSql = Regex.Replace(itemSql, string.Format(@"\|\|{0}\|\|", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
|
itemSql = Regex.Replace(itemSql, string.Format(@"\|\|{0}\|\|", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
|
||||||
return itemSql;
|
return itemSql;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user