Telerik ORM : Row not found: GenericOID@ OptimisticVerificationException
This kind of error occurred When DataAccess tries to update the row in the database which has the original values for the fields that have changed.
The reason the update fails is that the artificial columns added at runtime are nullable but the CLR property which these columns are mapped to are all non-nullable. Ex – bit column is mapped to Boolean CLR property.
The generated UPDATE statement tries to find a row with the CLR default value i.e 0 but the value in the column is NULL.
I have updated the method that maps the artificial properties as follows –
var propType = Type.GetType(property.PropertyType);
if(propType.IsValueType)
{
propType = GetNullableType(propType);
}
var primitivePropertyConfiguration = myConfig.HasArtificialPrimitiveProperty(property.PropertyName,propType).HasFieldName(property.PropertyName);
Here I check if the Type of the field is a value type and if it is, then I create a nullable CLR type instead of the non-nullable type.
The helper method used is as below
public static Type GetNullableType(Type type)
{
if (type.IsValueType)
{
Type nullable = typeof(Nullable);
return nullable.MakeGenericType(new[] { type });
}
return type;
}
Hope this help !
Comments