We have a project running: LLBLGen 5.10.1 - SelfServicing (Two Classes) - SQL Server 2017 - .NET Framework 4.8
In the context of a web application, I was just wondering what the correct instantiation and lifetime for LinqMetaData and QueryFactory would be when they are in a Repository registered as a Service in Dependency Injection.
using Autofac.Extensions.DependencyInjection;
using Autofac.Integration.Web;
using Autofac.Integration.WebApi;
using Microsoft.Extensions.DependencyInjection;
// Provider that holds the application container.
static IContainerProvider _containerProvider;
// Instance property that will be used by Autofac HttpModules to resolve and inject dependencies.
public IContainerProvider ContainerProvider
{
get { return _containerProvider; }
}
public class Global : HttpApplication, IContainerProviderAccessor
{
void RegisterServices(CommonSettings settings)
{
var services = new ServiceCollection();
.
.
.
services.AddScoped<InvoiceRepository>();
// Build up your application container and register your dependencies.
var containerBuilder = new ContainerBuilder();
containerBuilder.Populate(services);
var container = containerBuilder.Build();
_containerProvider = new ContainerProvider(container);
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
}
public class InvoiceRepository
{
readonly QueryFactory qf;
public InvoiceRepository()
{
qf = new QueryFactory();
}
public async Task<InvoiceDTO> GetInvoiceAsync(Guid id)
{
// Is this better
var q = qf.Create();
}
public async Task<InvoiceDTO> GetInvoiceAsync(Guid id)
{
// Or is this better
var qf = new QueryFactory();
var q = qf.Create();
}
}
Our database does have over 300 tables so there are hudnreds of Objects in Managed Memory in the Diagnostics Tools (when debugging).
Tons of Func<>, Action<>, ....StaticMetaData ...Factory, all related to SD.LLBLGen.Pro.
I am slowly replacing all LINQ queries with QuerySpec through the solution.
Attachments
Filename |
File size |
Added on |
Approval |
memory.png
|
69,001 |
10-Apr-2024 17:11.48 |
Approved |