54 lines
2.0 KiB
C#
54 lines
2.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace bdHerramientaCACOA.dbcontext
|
|
{
|
|
public class tsHerramientasCACOA:bdHerramientaCACOA.dbcontext.herramientascacoaContext
|
|
{
|
|
public static bool Cargado = false;
|
|
private static String? _Ip = null;
|
|
public string? ip
|
|
{
|
|
get
|
|
{
|
|
return _Ip;
|
|
}
|
|
set
|
|
{
|
|
_Ip = value;
|
|
}
|
|
}
|
|
|
|
public string Aplicaciones { get; private set; }
|
|
|
|
private static string? ConexionPorDefecto = null;
|
|
public static void EstableceCBD(string WriteConnection, string ReadOnlyConnection, bool soloLectura = false)
|
|
{
|
|
Utilidades.CadenaConexionBD = soloLectura ? ReadOnlyConnection : WriteConnection;
|
|
Utilidades.CadenaConexionBD_SL = ReadOnlyConnection;
|
|
}
|
|
public static tsHerramientasCACOA NuevoContexto(string NombreConexion = "", bool Lazy = true, bool SoloLectura = false, bool ConEventoSavingChanges = false, string aplicaciones = "")
|
|
{
|
|
string? cnx = Utilidades.CadenaConexionBD;
|
|
if (SoloLectura) cnx = Utilidades.CadenaConexionBD_SL;
|
|
|
|
var ob = new DbContextOptionsBuilder<herramientascacoaContext>();
|
|
// ob.UseLoggerFactory(_myLoggerFactory);
|
|
// ob.UseInternalServiceProvider(<EnumeracionesService>)
|
|
ob.UseMySql(cnx, Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.2.0-mysql"));
|
|
if (Lazy) ob.UseLazyLoadingProxies();
|
|
if (SoloLectura) ob.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
|
var Opciones = ob.Options;
|
|
tsHerramientasCACOA bd = new tsHerramientasCACOA(Opciones);
|
|
bd.Aplicaciones = aplicaciones;
|
|
return bd;
|
|
|
|
}
|
|
|
|
public tsHerramientasCACOA(DbContextOptions<herramientascacoaContext> Opciones) : base(Opciones)
|
|
{
|
|
if (_Ip == null) { ip = tsEFCore8.bbdd.ObtieneIPMysql(this); }
|
|
else { ip = _Ip; }
|
|
}
|
|
}
|
|
}
|