Yes, I set it to my timezone which is Beirut. How can I check the value of the timezone being set while running the app?
Okay, I have an update!
The date 3/11/2000 21:00:00
is indeed a UTC date representation of 4/11/2000 00:00:00+3
that I receive from the client.
When the client renders the value it is being rendered correct as 4/11/2000
.
Now, when exporting to Excel:
tempDateTime = Clock.Normalize(dateTime.Value);
tempDateTime is just the date stored in the Database in UTC format.
This line below, is keeping the date in UTC format, hence the reason I am getting this weird behavior:
value = _timeZoneConverter.Convert(tempDateTime);
Why the _timeZoneConverter is not picking up the Timezone set in the application and convertnig the date to it accordingly?
Thanks
Thanks :)
Hi, I have a calendar control to receive the Date of Birth of the person. The application zone is set to Beirut which is +2 GMT. On the server, I am using Utc Provider.
So, let's say the user selects his birthday as 4/11/2000, since I am using PrimeNG date picker, I see the date stored in the DB as 3/11/2000 21:00:00. (In summer, we are +3 GMT)
Next time, I want to edit the record, also, the Date of Birth shows as 4/11/2000.
Now, when I want to export the data to Excel, because I had the need to use PIVOTs in TSQL, so I am using a DataTable to read the data from the SQL (calling a Stored Procedure).
When I export the data, I see the Date of Birth field as 3/11/2000
Here is the code I am using to parse and format date in Excel:
case "System.DateTime":
var dateTime = (DateTime?)pocDataTable.Rows[r][columnName];
DateTime? tempDateTime = null;
if (dateTime.HasValue)
{
tempDateTime = Clock.Normalize(dateTime.Value);
}
value = _timeZoneConverter.Convert(tempDateTime);
break;
Hi, I finally made it work. In one of the entities, I need to provide a value for Id. However, Id is configured to be Identity Column.
Therefore, I had to make use of the following:
_context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.DrcYesNoDecline ON");
...
_context.SaveChanges();
_context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.DrcYesNoDecline OFF");
I noticed the following.
var item = new SpecificNeed("Child at risk");
The object item
has Id
equal to 0.
After running the line below:
var parent = _context.SpecificNeeds.Add(item).Entity;
Now parent
object has Id
with a value of -2147482647
Isn't that weird?
I run the script on the database you mean?
Hi @ismcagdas
It is: SQL Server 2016
Hello @alper,
This is the stack trace.
at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(RelationalDataReader reader)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(Tuple`2 parameters)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_0`2.<Execute>b__0(DbContext c, TState s)
at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, Func`2 operation, Func`2 verifySucceeded, TState state)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Abp.EntityFrameworkCore.AbpDbContext.SaveChanges()
at Tekvention.DrcApp.Migrations.Seed.DefaultSpecificNeedsCreator._create()
at Tekvention.DrcApp.Migrations.Seed.DefaultSpecificNeedsCreator.Create()
at Tekvention.DrcApp.Migrations.Seed.DefaultDrcBuilder.CreateDefaultDrcEntities()
at Tekvention.DrcApp.Migrations.Seed.DefaultDrcBuilder.Create()
at Tekvention.DrcApp.Migrations.Seed.SeedHelper.SeedHostDb(DrcAppDbContext context)
at Tekvention.DrcApp.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action`1 contextAction)
at Tekvention.DrcApp.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver)
at Tekvention.DrcApp.Entity.DrcAppEntityFrameworkCoreModule.PostInitialize()
at Abp.Modules.AbpModuleManager.<>c.<StartModules>b__15_2(AbpModuleInfo module)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Abp.Modules.AbpModuleManager.StartModules()
at Abp.AbpBootstrapper.Initialize()
Actually, I am not adding any value for the ID. This code was working before. Now on the new machine it is not.
I am just seeding some values and that's where I am getting the exception.
private void _create()
{
//Create if table is empty
if (!_context.SpecificNeeds.Any())
{
var parent = _context.SpecificNeeds.Add(new SpecificNeed("Child at risk")).Entity;
_context.SaveChanges(); // Exception here
Hi, I am running my application on a new laptop. I installed the database via update-database command and then tried to run the app. I get the following exception:
"Cannot insert explicit value for identity column in table 'XXX' when IDENTITY_INSERT is set to OFF."
The exception occurs on this line:
var parent = _context.SpecificNeeds.Add(new SpecificNeed("Child at risk")).Entity;
_context.SaveChanges();
All was working fine on the previous machine.
Any idea what might be the problem?