refactor(dbcontext): add NET/NETFRAMEWORK conditional compilation
- Wrapped `using` directives with `#if NET` and `#elif NETFRAMEWORK` - Applied conditional inheritance for `IUserManagerDbContext` and `IMailDbContext` - Made `EmailOut` DbSet and triggers only available in `NET` builds - Adjusted `_logger` nullability for NET vs NETFRAMEWORK targets - Ensured `modelBuilder.ConfigureUserManager()` only runs in NET builds
This commit is contained in:
parent
9c867ac8aa
commit
ca24afe3c6
@ -1,18 +1,26 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Group = DigitalData.UserManager.Domain.Entities.Group;
|
||||
using Module = DigitalData.UserManager.Domain.Entities.Module;
|
||||
using DigitalData.EmailProfilerDispatcher;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.Core.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using DigitalData.EmailProfilerDispatcher;
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
|
||||
using DigitalData.UserManager.Infrastructure;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using DigitalData.Core.Client;
|
||||
using EnvelopeGenerator.Application.Common.Configurations;
|
||||
#elif NETFRAMEWORK
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Infrastructure;
|
||||
namespace EnvelopeGenerator.Infrastructure
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
public class EGDbContext : EGDbContextBase
|
||||
{
|
||||
@ -22,7 +30,10 @@ public class EGDbContext : EGDbContextBase
|
||||
}
|
||||
|
||||
//TODO: Adding EmailOut instead of EmailOut.Abst is not correct for the arch. Re-design EmailPut consedering this. IMailDbContext shoud move to Abstraction layer (hint: in this case using DBSet in abst. will be problem because entity framework will have to be added.
|
||||
public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailDbContext
|
||||
public abstract class EGDbContextBase : DbContext
|
||||
#if NET
|
||||
, IUserManagerDbContext, IMailDbContext
|
||||
#endif
|
||||
{
|
||||
public DbSet<Config> Configs { get; set; }
|
||||
|
||||
@ -56,7 +67,9 @@ public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailD
|
||||
|
||||
public DbSet<UserRep> UserReps { get; set; }
|
||||
|
||||
#if NET
|
||||
public DbSet<EmailOut> EMailOuts { get; set; }
|
||||
#endif
|
||||
|
||||
public DbSet<EnvelopeReceiverReadOnly> EnvelopeReceiverReadOnlys { get; set; }
|
||||
|
||||
@ -64,7 +77,11 @@ public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailD
|
||||
|
||||
private readonly DbTriggerParams _triggers;
|
||||
|
||||
private readonly ILogger? _logger;
|
||||
private readonly ILogger
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
_logger;
|
||||
|
||||
public bool IsMigration { get; set; } = false;
|
||||
|
||||
@ -89,7 +106,9 @@ public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailD
|
||||
Modules = Set<Module>();
|
||||
Users = Set<User>();
|
||||
UserReps = Set<UserRep>();
|
||||
#if NET
|
||||
EMailOuts = Set<EmailOut>();
|
||||
#endif
|
||||
EnvelopeReceiverReadOnlys = Set<EnvelopeReceiverReadOnly>();
|
||||
}
|
||||
|
||||
@ -210,12 +229,20 @@ public abstract class EGDbContextBase : DbContext, IUserManagerDbContext, IMailD
|
||||
AddTrigger<EnvelopeReceiverReadOnly>();
|
||||
AddTrigger<EnvelopeType>();
|
||||
AddTrigger<Receiver>();
|
||||
#if NET
|
||||
AddTrigger<EmailOut>();
|
||||
#endif
|
||||
#endregion Trigger
|
||||
|
||||
//configure model builder for user manager tables
|
||||
#if NET
|
||||
modelBuilder.ConfigureUserManager();
|
||||
#endif
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user