mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Upgrade There is no entity update operation
This commit is contained in:
parent
0906ae8ecf
commit
e4cc3424c8
@ -287,6 +287,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return columnInfo.InsertSql;
|
return columnInfo.InsertSql;
|
||||||
}
|
}
|
||||||
|
else if (columnInfo.SqlParameterDbType is Type && (Type)columnInfo.SqlParameterDbType == UtilConstants.SqlConvertType)
|
||||||
|
{
|
||||||
|
var type = columnInfo.SqlParameterDbType as Type;
|
||||||
|
var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(typeof(string));
|
||||||
|
var obj = Activator.CreateInstance(type);
|
||||||
|
var p = ParameterConverter.Invoke(obj, new object[] { columnInfo.Value, GetDbColumnIndex }) as SugarParameter;
|
||||||
|
return p.ParameterName;
|
||||||
|
}
|
||||||
else if (columnInfo.SqlParameterDbType is Type)
|
else if (columnInfo.SqlParameterDbType is Type)
|
||||||
{
|
{
|
||||||
var type=columnInfo.SqlParameterDbType as Type;
|
var type=columnInfo.SqlParameterDbType as Type;
|
||||||
|
@ -402,7 +402,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return columnInfo.UpdateSql;
|
return columnInfo.UpdateSql;
|
||||||
}
|
}
|
||||||
else if (columnInfo.SqlParameterDbType is Type)
|
else if (columnInfo.SqlParameterDbType is Type&& (Type)columnInfo.SqlParameterDbType == UtilConstants.SqlConvertType)
|
||||||
|
{
|
||||||
|
var type = columnInfo.SqlParameterDbType as Type;
|
||||||
|
var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(typeof(string));
|
||||||
|
var obj = Activator.CreateInstance(type);
|
||||||
|
var p = ParameterConverter.Invoke(obj, new object[] { columnInfo.Value, GetDbColumnIndex }) as SugarParameter;
|
||||||
|
return p.ParameterName;
|
||||||
|
}
|
||||||
|
else if (columnInfo.SqlParameterDbType is Type)
|
||||||
{
|
{
|
||||||
var type = columnInfo.SqlParameterDbType as Type;
|
var type = columnInfo.SqlParameterDbType as Type;
|
||||||
var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(columnInfo.PropertyType);
|
var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(columnInfo.PropertyType);
|
||||||
|
@ -531,6 +531,20 @@ namespace SqlSugar
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public IUpdateable<T> SetColumns(Expression<Func<T, object>> filedNameExpression, Expression<Func<T, object>> valueExpression)
|
||||||
|
{
|
||||||
|
var name = UpdateBuilder.GetExpressionValue(filedNameExpression, ResolveExpressType.FieldSingle).GetString();
|
||||||
|
name = UpdateBuilder.Builder.GetNoTranslationColumnName(name);
|
||||||
|
var value = UpdateBuilder.GetExpressionValue(valueExpression, ResolveExpressType.FieldSingle).GetString();
|
||||||
|
this.UpdateBuilder.DbColumnInfoList.Add(new DbColumnInfo()
|
||||||
|
{
|
||||||
|
DbColumnName = name,
|
||||||
|
Value = value,
|
||||||
|
PropertyName = name ,
|
||||||
|
SqlParameterDbType=typeof(SqlSugar.DbConvert.NoParameterCommonPropertyConvert)
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public IUpdateable<T> SetColumns(Expression<Func<T, object>> filedNameExpression, object fieldValue)
|
public IUpdateable<T> SetColumns(Expression<Func<T, object>> filedNameExpression, object fieldValue)
|
||||||
{
|
{
|
||||||
var name= UpdateBuilder.GetExpressionValue(filedNameExpression,ResolveExpressType.FieldSingle).GetString();
|
var name= UpdateBuilder.GetExpressionValue(filedNameExpression,ResolveExpressType.FieldSingle).GetString();
|
||||||
|
@ -33,7 +33,24 @@ namespace SqlSugar.DbConvert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class NoParameterCommonPropertyConvert : ISugarDataConverter
|
||||||
|
{
|
||||||
|
public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
|
||||||
|
{
|
||||||
|
if (columnValue == null)
|
||||||
|
{
|
||||||
|
new SugarParameter("null", null, null);
|
||||||
|
}
|
||||||
|
return new SugarParameter(columnValue+"", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T QueryConverter<T>(IDataRecord dr, int i)
|
||||||
|
{
|
||||||
|
|
||||||
|
var value = dr.GetValue(i);
|
||||||
|
return (T)UtilMethods.ChangeType2(value, typeof(T));
|
||||||
|
}
|
||||||
|
}
|
||||||
public class CommonPropertyConvert : ISugarDataConverter
|
public class CommonPropertyConvert : ISugarDataConverter
|
||||||
{
|
{
|
||||||
public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
|
public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
|
||||||
|
@ -77,6 +77,7 @@ namespace SqlSugar
|
|||||||
IUpdateable<T> SetColumns(string fieldName,object fieldValue);
|
IUpdateable<T> SetColumns(string fieldName,object fieldValue);
|
||||||
|
|
||||||
IUpdateable<T> SetColumns(Expression<Func<T,object>> filedNameExpression, object fieldValue);
|
IUpdateable<T> SetColumns(Expression<Func<T,object>> filedNameExpression, object fieldValue);
|
||||||
|
IUpdateable<T> SetColumns(Expression<Func<T, object>> filedNameExpression, Expression<Func<T, object>> valueExpression);
|
||||||
IUpdateable<T> SetColumnsIF(bool isUpdateColumns, Expression<Func<T, object>> filedNameExpression, object fieldValue);
|
IUpdateable<T> SetColumnsIF(bool isUpdateColumns, Expression<Func<T, object>> filedNameExpression, object fieldValue);
|
||||||
IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns,Expression<Func<T, object>> columns);
|
IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns,Expression<Func<T, object>> columns);
|
||||||
IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, params string[] columns);
|
IUpdateable<T> UpdateColumnsIF(bool isUpdateColumns, params string[] columns);
|
||||||
|
@ -46,6 +46,8 @@ namespace SqlSugar
|
|||||||
internal static Type DicArraySS = typeof(Dictionary<string, string>);
|
internal static Type DicArraySS = typeof(Dictionary<string, string>);
|
||||||
internal static Type DicArraySO = typeof(Dictionary<string, object>);
|
internal static Type DicArraySO = typeof(Dictionary<string, object>);
|
||||||
|
|
||||||
|
public static Type SqlConvertType = typeof(SqlSugar.DbConvert.NoParameterCommonPropertyConvert);
|
||||||
|
|
||||||
public static Type SugarType = typeof(SqlSugarProvider);
|
public static Type SugarType = typeof(SqlSugarProvider);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user