a.m. wrote:NEW MINOR VERSION:
We've released a new version - 4.40.3. This is a minor release that is fully compatible with the previous versions (4.40.0- 4.40.2). So all third-party plugins for 4.40 work for all minor versions (4.40.0-4.40.3).
Hi Andrei,
After upgrading to 4.40.3, our clients reported that some of our plugins are not working properly.
We are no longer able to save
TimeSpan fields into the database.
We have
Schedule entity has some
TimeSpan properties like these (deleted the rest as they are not important) :
public class Schedule : BaseEntity
{ ...
public TimeSpan? SchedulePatternFromTime { get; set; }
public TimeSpan? SchedulePatternToTime { get; set; }
...
}
We have a ScheduleBuilder that maps them like this:
table
.WithColumn(nameof(Schedule.SchedulePatternFromTime)).AsCustom("TIME").Nullable()
.WithColumn(nameof(Schedule.SchedulePatternToTime)).AsCustom("TIME").Nullable();
The columns in the database are properly set to "time(7)" so the mapping to the database seems to be working fine but neither
Insert nor
Update are working.
This used to be working fine until we upgraded to nopCommerce 4.40.3 and now when we try to insert or update a
Schedule entity with any value different than null it throws this error:
Short message:
Failed to convert parameter value from a TimeSpan to a DateTime.Full Error:
System.InvalidCastException: Failed to convert parameter value from a TimeSpan to a DateTime.
---> System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
at System.Data.SqlClient.SqlParameter.GetCoercedValue()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.BeginExecuteReader(AsyncCallback callback, Object stateObject, CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.<>c__DisplayClass130_0.<ExecuteReaderAsync>b__1(CommandBehavior commandBehavior, AsyncCallback callback, Object stateObject)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1](Func`4 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory`1.FromAsync[TArg1](Func`4 beginMethod, Func`2 endMethod, TArg1 arg1, Object state)
at System.Data.SqlClient.SqlCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
--- End of stack trace from previous location ---
at LinqToDB.Data.DataConnection.ExecuteScalarAsync(CancellationToken cancellationToken)
at LinqToDB.Data.DataConnection.QueryRunner.ExecuteScalarAsync(CancellationToken cancellationToken)
at LinqToDB.Linq.QueryRunner.ScalarQueryAsync(Query query, IDataContext dataContext, Expression expression, Object[] ps, Object[] preambles, CancellationToken cancellationToken)
at LinqToDB.Linq.QueryRunner.InsertWithIdentity`1.QueryAsync(IDataContext dataContext, T obj, InsertColumnFilter`1 columnFilter, String tableName, String serverName, String databaseName, String schemaName, TableOptions tableOptions, CancellationToken token)
at LinqToDB.DataExtensions.InsertWithInt32IdentityAsync[T](IDataContext dataContext, T obj, InsertColumnFilter`1 columnFilter, String tableName, String databaseName, String schemaName, String serverName, TableOptions tableOptions, CancellationToken token)
at LinqToDB.DataExtensions.InsertWithInt32IdentityAsync[T](IDataContext dataContext, T obj, String tableName, String databaseName, String schemaName, String serverName, TableOptions tableOptions, CancellationToken token)
at Nop.Data.DataProviders.BaseDataProvider.InsertEntityAsync[TEntity](TEntity entity)We are properly setting the values to be of type TimeSpan so it is not a problem on our end (the code has not been changed since 4.40.2 on our side).
Any idea why this is no longer working?
Do you think it is related to switching back to Autofaq container somehow?
Any help with this will be much appreciated since this Scheduling component is used in several of our plugins that come with our themes and now all our clients that are on nopCommerce 4.40.3 will not be able to use them.
Thanks,
Boyko