Bug: No coercion operator is defined between types 'System.TimeSpan' and 'System.Int64'.
See original GitHub issueHi, I updated from 1.12.9 to 1.12.10 (using C#). The following property-handler doesn’t work. It works for reading, but not for writing (insert/update). (I mentioned it in #1021)
public class TestClass
{
public long ID {get;set;}
public TimeSpan TestFieldTimeSpan {get;set;}
}
public class PropertyHandlerTimeSpan : IPropertyHandler<long, TimeSpan>
{
public TimeSpan Get(long p, ClassProperty property) => new TimeSpan(p);
public long Set(TimeSpan p, ClassProperty property) => p.Ticks;
}
FluentMapper.Entity<TestClass>().PropertyHandler<PropertyHandlerTimeSpan>(p=>p.TestFieldTimeSpan );
Exception: "Compiler.Entity/Object.Property: Failed to convert the value expression for property handler ‘PropertyHandlerTimeSpan’. ClassProperty :: Name = TestFieldTimeSpan (System.TimeSpan), DeclaringType = TestClass
at RepoDb.Reflection.Compiler.GetEntityInstancePropertyValueExpression(Expression entityInstanceExpression, ClassProperty classProperty, DbField dbField)
at RepoDb.Reflection.Compiler.GetDataEntityDbParameterValueAssignmentExpression(ParameterExpression parameterVariableExpression, Expression entityExpression, ParameterExpression propertyExpression, ClassProperty classProperty, DbField dbField, IDbSetting dbSetting)
at RepoDb.Reflection.Compiler.GetDataEntityParameterAssignmentExpression(ParameterExpression commandParameterExpression, Int32 entityIndex, Expression entityExpression, ParameterExpression propertyExpression, DbField dbField, ClassProperty classProperty, ParameterDirection direction, IDbSetting dbSetting)
at RepoDb.Reflection.Compiler.GetPropertyFieldExpression(ParameterExpression commandParameterExpression, Expression entityExpression, FieldDirection fieldDirection, Int32 entityIndex, IDbSetting dbSetting)
at RepoDb.Reflection.Compiler.CompileDataEntityDbParameterSetter(Type entityType, IEnumerable`1 inputFields, IEnumerable`1 outputFields, IDbSetting dbSetting)
at RepoDb.Reflection.FunctionFactory.CompileDataEntityDbParameterSetter(Type entityType, IEnumerable`1 inputFields, IEnumerable`1 outputFields, IDbSetting dbSetting)
at RepoDb.FunctionCache.DataEntityDbParameterSetterCache.Get(Type entityType, String cacheKey, IEnumerable`1 inputFields, IEnumerable`1 outputFields, IDbSetting dbSetting)
at RepoDb.FunctionCache.GetDataEntityDbParameterSetterCompiledFunction(Type entityType, String cacheKey, IEnumerable`1 inputFields, IEnumerable`1 outputFields, IDbSetting dbSetting)
at RepoDb.Contexts.Providers.UpdateExecutionContextProvider.CreateInternal(Type entityType, IDbConnection connection, String tableName, IEnumerable`1 dbFields, IEnumerable`1 fields, String commandText)
at RepoDb.Contexts.Providers.UpdateExecutionContextProvider.<CreateAsync>d__2.MoveNext()
Inner Exception: “No coercion operator is defined between types ‘System.TimeSpan’ and ‘System.Int64’.”
at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
at RepoDb.Reflection.Compiler.ConvertExpressionToTypeExpression(Expression expression, Type toType)
at RepoDb.Reflection.Compiler.ConvertExpressionToNullableExpression(Expression expression, Type targetNullableType)
at RepoDb.Reflection.Compiler.ConvertExpressionToPropertyHandlerSetExpressionTuple(Expression expression, ClassProperty classProperty, Type targetType)
at RepoDb.Reflection.Compiler.ConvertExpressionToPropertyHandlerSetExpression(Expression expression, ClassProperty classProperty, Type targetType)
at RepoDb.Reflection.Compiler.GetEntityInstancePropertyValueExpression(Expression entityInstanceExpression, ClassProperty classProperty, DbField dbField)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
No coercion operator is defined between types 'System. ...
No coercion operator is defined between types 'System.DateTime' and 'System.Nullable`1[System.TimeSpan]' #23784.
Read more >Expression Cast Error - No coercion operator is defined ...
When I hit "Cast" function I am getting following error: No coercion operator is defined between types 'System.Func`2[CommentUrlCommon,System.
Read more >Advice on "no coercion operator is defined between types ' ...
Due to how MySql holds Booleans in Integer fields when the EF hits a boolean I get: "No coercion operator is defined between...
Read more >Filter a column with custom type - "No coercion operator is ...
Hello! I'm trying to enable filtering on a column which is bound to a property of a object whose structure is something like...
Read more >Error while patching: "No coercion operator is def...
I get the above error while trying to update records in my SQL able. I pulled data from this table into power apps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for this hint, but currently it’s not absolutely necessary to use 1.12.10 😉
Please be informed of our delta changes. In this release, we have so many breaking changes. This is the reason why we are having delays on our releases.