powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / TimeSpan and save
3 сообщений из 3, страница 1 из 1
TimeSpan and save
    #38941413
Andrey1306
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Добрый день.

Есть модель с типами

[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:hh:mm tt}")]
public TimeSpan? Time_Finish { get; set; }

инпуты так

@Html.TextBoxFor(model => model.Time_Finish, new { @class = "form-control", @placeholder = "ГГ:ХХ" })
@Html.ValidationMessageFor(model => model.Time_Finish, "", new { @class = "text-danger" })

поверху еще http://eonasdan.github.io/bootstrap-datetimepicker/#custom-formats навернут с такой инициализацией
Код: javascript
1.
2.
3.
4.
5.
6.
7.
8.
9.
...
.timepicker({
                template: false,
                showInputs: false,
                minuteStep: 1,
                showMeridian: false,
                defaultTime: false,
              
            });



В таблице MS SQL есть поле [Time_Finish] [time](0) NULL

Запись в базу при помощи EF 6.0 ххххх.Time_Finish = model.Time_Finish; в 99.5 % (примерно) срабатывает, но иногда получаю в логе (логируется catch (EntityCommandExecutionException er) ) такую вот сообщение и соответсвенно откат сохранения
кратко

Код: c#
1.
 SqlDbType.Time overflow.  Value '17.00:00:00' is out of range.  Must be between 00:00:00.0000000 and 23:59:59.9999999.




Помогите разобраться откуда точка берется в TimeSpan ?

Спасибо



=полностью_текст_ошибки
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.OverflowException: SqlDbType.Time overflow. Value '17.00:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999.
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam)
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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
--- End of inner exception stack trace ---
at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
...
Рейтинг: 0 / 0
TimeSpan and save
    #38941425
handmadeFromRu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
TimeSpan and save
    #38941532
Andrey1306
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
handmadeFromRu тык
тык

Спасибо, не понятно только , как пользователь умудряется ввести время большее за 23:59
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / TimeSpan and save
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]