You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The check in MemberMapper.cs for type compatability between the backing field and the associated property it too aggressive. It is currently:
if (!fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(property.ClrType.GetTypeInfo()))
{
throw new InvalidOperationException(
Strings.BadBackingFieldType(fieldName, fieldInfo.FieldType.Name, entityType.Name, propertyName, property.ClrType.Name));
}
This does not allow for simple type conversion between the backing field and the domain property, which is useful when the store type does not exactly match the domain type.
public class ExampleEntity
{
private int _foo; // Store type is int
public ushort Foo { get { return (ushort)_foo; } } // Domain type is actually ushort, but the store does not support unsigned.
}
The backing field can in this case always hold the value of the property, and so it should also pass the check. Note that typeof(int).IsAssignableFrom(typeof(ushort)) is false.
The text was updated successfully, but these errors were encountered:
Triage We have a work item to properly support type conversion (#242). What you probably want to do here is have everything in the CLR type defined as ushort and just have EF do the conversion. In the meantime, you could expose a private property typed as int and have EF map to that.
The check in
MemberMapper.cs
for type compatability between the backing field and the associated property it too aggressive. It is currently:This does not allow for simple type conversion between the backing field and the domain property, which is useful when the store type does not exactly match the domain type.
The backing field can in this case always hold the value of the property, and so it should also pass the check. Note that
typeof(int).IsAssignableFrom(typeof(ushort))
isfalse
.The text was updated successfully, but these errors were encountered: