nicke
nicke
CC#
Created by nicke on 3/8/2024 in #help
EF Core how can I access temporal table PeriordStart value to use it for "last modified" information
From the docs: var validFrom = foo.Property<DateTime>("VALID_FROM").CurrentValue; This works and i get the correct DateTime for when the row was last modified. But this is not very nice to do. I would like to be able to access this VALID_FROM via foo.ModifiedUtc My temporal definiton
builder
.ToTable(
"FOO",
b => b.IsTemporal(
tableBuilder =>
{
tableBuilder.HasPeriodStart("VALID_FROM");
tableBuilder.HasPeriodEnd("VALID_TO");
tableBuilder.UseHistoryTable("FOO_HISTORU");
}));
builder
.ToTable(
"FOO",
b => b.IsTemporal(
tableBuilder =>
{
tableBuilder.HasPeriodStart("VALID_FROM");
tableBuilder.HasPeriodEnd("VALID_TO");
tableBuilder.UseHistoryTable("FOO_HISTORU");
}));
What i've tried: Decorate the ModifiedUtc property with a [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
builder
.Property(cc => cc.ModifiedUtc)
.HasColumnName("VALID_FROM")
// Prevent EF from using this property in insert / update statements.
.ValueGeneratedOnAddOrUpdate();
builder
.Property(cc => cc.ModifiedUtc)
.HasColumnName("VALID_FROM")
// Prevent EF from using this property in insert / update statements.
.ValueGeneratedOnAddOrUpdate();
But this just ends in an exception: Microsoft.Data.SqlClient.SqlException : Invalid column name 'VALID_FROM1'. So EF seems to enumerate one of my mappings by adding a 1 after the column name.
2 replies
CC#
Created by nicke on 1/18/2024 in #help
AspNet.Core OpenTelemetry AzureMonitorLogExporter doesn't include ILogger name in AppInsight traces.
ILogger log messages get written to app insights but there is some info missing compared to writing to for example file or console. Console: InternalApi.DashboardController: Information: This is a info App insights: Does not contain any additional infromation except the LogLevel and the message. Can I somehow add more information to the traces or do i need to use Microsoft.ApplicationInsights.AspNetCore if i want that?
44 replies
CC#
Created by nicke on 12/21/2023 in #help
Have all ControllerBase ObjectResults return StatusCodeResult with ProblemDetails
I'd like to unify the way errors are returned from my web api. With the introduction of AddProblemDetails this is pretty easy to do when a IAction returns a StatusCodeResult The problem is i have hunderds of places where I already return a ObjectResult for example BadRequest("foo") and this just creates a text/plain response instead of the desired ProblemDetails. Is there any clean way to achieve this in a clean way,? Or do i just need to override all usages of ObjectResult responses in ControllerBase?
5 replies
CC#
Created by nicke on 8/9/2023 in #help
❔ GetOwinContext().Authentication.GetAuthenticationTypes() equivalent in asp.net core
Trying to migrate a asp.net MVC project to asp.net core and having trouble figuring out what authentication middlewares have been registred for usege on the client side.
55 replies
CC#
Created by nicke on 3/6/2023 in #help
❔ Update of runtime and restarting application (Windows service)
There seems to be some issue for us when the runtime updates. We dynamically load some libraries and after window update updates the runtime we get the following error for system libraries. System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.Compression.ZipFile, Version=6.0.0.0... Is this by design and is there any way around it or is it a bug in our application how we handle loading? Is the only option to disable windows updates and handle everything manually? Having a hard time finding anything about this online.
2 replies
CC#
Created by nicke on 10/26/2022 in #help
AssemblyLoadContext not unloading if system.runtime.caching MemoryCache used inside ALC.
Our use cases allows third parties to create plugins, so we do not have full control of how they are implemented. When using AppDomains in .net framework MemoryCache was disposed internally by the MemoryCache implementation when AppDomain unloaded see: https://github.com/microsoft/referencesource/blob/dae14279dd0672adead5de00ac8f117dcf74c184/System.Runtime.Caching/System/Caching/MemoryCache.cs#L185 Problem is the unload event is not implemented in .NET 6 for AppDomains. https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/AppDomain.cs#L67 Is there any other way than fixing the plugin code to listen for AssemblyLoadContext.Unloading event and Dispose of the MemoryCache?
1 replies