Closed poudigne closed 9 years ago
After looking at your code I have found in your class SqlDataProviderBase.SetParameterValue. You have this line of code
if (parameter.DbType == DbType.String && ((string)value).Length == 0) parameter.Size = 1;
This mean, as soon as you have an empty string you set the parameter size that you reuse after that to 1 and it breaks everthing. I don't know what's the best fix for that... but for now ill just comment the line for my personnal use.
Can you give minimal test sample?
Commenting the line, worked for me. My co-worker is coding the test sample right now, will send right as soon as it's ready.
OK
About the int being NULL instead of 0. I found it was in this piece of code in DbManager.AssignParameterValue()
:
_dataProvider.SetParameterValue(
Parameter(name),
value == null || mm.MapMemberInfo.Nullable && _mappingSchema.IsNull(value)?
DBNull.Value: value)
public virtual bool IsNull(object value)
{
return TypeAccessor.IsNull(value);
}
private static bool IsNullInternal(object value) // value = 0
{
if (value == null)
return true;
var nullValue = GetNullValue(value.GetType()); // nullValue = 0
return nullValue != null && value.Equals(nullValue); // 0 != null && 0 == 0 ==> true
}
_mappingSchema.IsNull(value)
Return true. Again, not sure if it was intended to. but I need to insert 0 instead of Null.
(i'll include a demo of this bug in the demo too)
Here's the demo (click the download link on top of the page) https://drive.google.com/file/d/0BzznvANFApmVYU55UUxBS0FncTA/view?usp=sharing
Are you gonna make a Fix for this?
Awesome, just updated BLToolkit. You seem to have fix the bug with the string, but not with the int. Thanks .
That's strange, nulls for ints should be also fixed, here is the test for your case https://github.com/igor-tkachev/bltoolkit/commit/ae7c14655f45b7ed436da965c460d9541602768a#diff-889a50237b1dd8e31c081c923d848f05R175
Thanks, ill take a deeper look on monday at work. Thank for the fix.
BLToolkit did not update correctly when I tested 2 days ago. But it works flawlessly now. You can close this issue. Thanks man.
After inserting a null or Empty in a specific column, the rest of the insertion in that same column is broken. Like... if it's a String it keep the first letter only, if it's a int and the value is 0 it will insert null.
See my question on Stack overflow for screenshot and more detail http://stackoverflow.com/questions/30979713/bltoolkit-save-null-instead-of-0