mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-07 06:07:59 +08:00
SqlParamter Bug
This commit is contained in:
parent
b6a57b3614
commit
d04240dc08
@ -41,6 +41,7 @@ namespace OrmTest.UnitTest
|
|||||||
};
|
};
|
||||||
var id = db.Insertable<DataTestInfo>(insertObject).ExecuteReutrnIdentity();
|
var id = db.Insertable<DataTestInfo>(insertObject).ExecuteReutrnIdentity();
|
||||||
var data = db.Queryable<DataTestInfo>().InSingle(id);
|
var data = db.Queryable<DataTestInfo>().InSingle(id);
|
||||||
|
db.Updateable(data).ExecuteCommand();
|
||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
public SqlSugarClient GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ namespace SqlSugar
|
|||||||
foreach (var item in this.InsertBuilder.DbColumnInfoList)
|
foreach (var item in this.InsertBuilder.DbColumnInfoList)
|
||||||
{
|
{
|
||||||
if (this.InsertBuilder.Parameters == null) this.InsertBuilder.Parameters = new List<SugarParameter>();
|
if (this.InsertBuilder.Parameters == null) this.InsertBuilder.Parameters = new List<SugarParameter>();
|
||||||
var paramters = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value);
|
var paramters = new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value,item.PropertyType);
|
||||||
if (InsertBuilder.IsInsertNull && paramters.Value == null) {
|
if (InsertBuilder.IsInsertNull && paramters.Value == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -155,6 +155,7 @@ namespace SqlSugar
|
|||||||
Value = column.PropertyInfo.GetValue(item,null),
|
Value = column.PropertyInfo.GetValue(item,null),
|
||||||
DbColumnName = GetDbColumnName(column.PropertyName),
|
DbColumnName = GetDbColumnName(column.PropertyName),
|
||||||
PropertyName = column.PropertyName,
|
PropertyName = column.PropertyName,
|
||||||
|
PropertyType=PubMethod.GetUnderType(column.PropertyInfo),
|
||||||
TableId = i
|
TableId = i
|
||||||
};
|
};
|
||||||
insertItem.Add(columnInfo);
|
insertItem.Add(columnInfo);
|
||||||
|
@ -145,6 +145,7 @@ namespace SqlSugar
|
|||||||
Value = column.PropertyInfo.GetValue(item, null),
|
Value = column.PropertyInfo.GetValue(item, null),
|
||||||
DbColumnName = GetDbColumnName(column.PropertyName),
|
DbColumnName = GetDbColumnName(column.PropertyName),
|
||||||
PropertyName = column.PropertyName,
|
PropertyName = column.PropertyName,
|
||||||
|
PropertyType=PubMethod.GetUnderType(column.PropertyInfo),
|
||||||
TableId = i
|
TableId = i
|
||||||
};
|
};
|
||||||
insertItem.Add(columnInfo);
|
insertItem.Add(columnInfo);
|
||||||
@ -171,7 +172,7 @@ namespace SqlSugar
|
|||||||
foreach (var item in this.UpdateBuilder.DbColumnInfoList)
|
foreach (var item in this.UpdateBuilder.DbColumnInfoList)
|
||||||
{
|
{
|
||||||
if (this.UpdateBuilder.Parameters == null) this.UpdateBuilder.Parameters = new List<SugarParameter>();
|
if (this.UpdateBuilder.Parameters == null) this.UpdateBuilder.Parameters = new List<SugarParameter>();
|
||||||
this.UpdateBuilder.Parameters.Add(new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value));
|
this.UpdateBuilder.Parameters.Add(new SugarParameter(this.SqlBuilder.SqlParameterKeyWord + item.DbColumnName, item.Value,item.PropertyType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace SqlSugar
|
|||||||
internal static Type GuidType = typeof(Guid);
|
internal static Type GuidType = typeof(Guid);
|
||||||
internal static Type DateType = typeof(DateTime);
|
internal static Type DateType = typeof(DateTime);
|
||||||
internal static Type ByteType = typeof(Byte);
|
internal static Type ByteType = typeof(Byte);
|
||||||
|
internal static Type ByteArrayType = typeof(byte[]);
|
||||||
internal static Type BoolType = typeof(bool);
|
internal static Type BoolType = typeof(bool);
|
||||||
internal static Type ObjType = typeof(object);
|
internal static Type ObjType = typeof(object);
|
||||||
internal static Type Dob = typeof(double);
|
internal static Type Dob = typeof(double);
|
||||||
|
@ -17,6 +17,13 @@ namespace SqlSugar
|
|||||||
return unType;
|
return unType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static Type GetUnderType(PropertyInfo propertyInfo)
|
||||||
|
{
|
||||||
|
Type unType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
|
||||||
|
unType = unType ?? propertyInfo.PropertyType;
|
||||||
|
return unType;
|
||||||
|
}
|
||||||
|
|
||||||
internal static T IsNullReturnNew<T>(T returnObj) where T : new()
|
internal static T IsNullReturnNew<T>(T returnObj) where T : new()
|
||||||
{
|
{
|
||||||
if (returnObj.IsNullOrEmpty())
|
if (returnObj.IsNullOrEmpty())
|
||||||
|
@ -11,6 +11,7 @@ namespace SqlSugar
|
|||||||
public string DbColumnName { get; set; }
|
public string DbColumnName { get; set; }
|
||||||
public string PropertyName { get; set; }
|
public string PropertyName { get; set; }
|
||||||
public string DataType { get; set; }
|
public string DataType { get; set; }
|
||||||
|
public Type PropertyType { get; set; }
|
||||||
public int Length { get; set; }
|
public int Length { get; set; }
|
||||||
public string ColumnDescription { get; set; }
|
public string ColumnDescription { get; set; }
|
||||||
public string DefaultValue { get; set; }
|
public string DefaultValue { get; set; }
|
||||||
|
@ -14,11 +14,33 @@ namespace SqlSugar
|
|||||||
this.Value = value;
|
this.Value = value;
|
||||||
this.ParameterName = name;
|
this.ParameterName = name;
|
||||||
}
|
}
|
||||||
public SugarParameter(string name, object value,bool isOutput)
|
public SugarParameter(string name, object value, Type type)
|
||||||
{
|
{
|
||||||
this.Value = value;
|
this.Value = value;
|
||||||
this.ParameterName = name;
|
this.ParameterName = name;
|
||||||
if (isOutput) {
|
if (type == PubConst.ByteArrayType)
|
||||||
|
{
|
||||||
|
this.DbType = System.Data.DbType.Binary;
|
||||||
|
}
|
||||||
|
else if (type == PubConst.GuidType)
|
||||||
|
{
|
||||||
|
this.DbType = System.Data.DbType.Guid;
|
||||||
|
}
|
||||||
|
else if (type == PubConst.IntType)
|
||||||
|
{
|
||||||
|
this.DbType = System.Data.DbType.Int32;
|
||||||
|
}
|
||||||
|
else if (type == PubConst.DateType)
|
||||||
|
{
|
||||||
|
this.DbType = System.Data.DbType.Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public SugarParameter(string name, object value, bool isOutput)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
this.ParameterName = name;
|
||||||
|
if (isOutput)
|
||||||
|
{
|
||||||
this.Direction = ParameterDirection.Output;
|
this.Direction = ParameterDirection.Output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +96,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public override DataRowVersion SourceVersion
|
public override DataRowVersion SourceVersion
|
||||||
{
|
{
|
||||||
get;set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ResetDbType()
|
public override void ResetDbType()
|
||||||
|
Loading…
Reference in New Issue
Block a user