38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using bdAntifraudeMYSQL.dbcontext;
|
|
|
|
namespace SwaggerAntifraudeMYSQL;
|
|
|
|
/// <summary>
|
|
/// Selecciona por nombre una entrada de bdAntifraudeMYSQL.dbcontext.Conexion.
|
|
/// La cadena de conexión sigue resolviéndose en la biblioteca MySQL existente.
|
|
/// </summary>
|
|
public static class ContextosMySql
|
|
{
|
|
private static string? _nombreConexion;
|
|
|
|
public static void Configurar(string? nombreConexion)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(nombreConexion))
|
|
throw new InvalidOperationException("Falta MySql:NombreConexion en la configuración de SwaggerAntifraudeMYSQL.");
|
|
|
|
_nombreConexion = nombreConexion;
|
|
}
|
|
|
|
public static tsGestionAntifraude NuevoContexto(
|
|
bool SoloLectura = false,
|
|
bool Lazy = true,
|
|
bool ConEventoSavingChanges = true,
|
|
string aplicaciones = "")
|
|
{
|
|
var nombreConexion = _nombreConexion
|
|
?? throw new InvalidOperationException("Configure MySql:NombreConexion antes de crear contextos.");
|
|
|
|
return tsGestionAntifraude.NuevoContexto(
|
|
NombreConexion: nombreConexion,
|
|
Lazy: Lazy,
|
|
SoloLectura: SoloLectura,
|
|
ConEventoSavingChanges: ConEventoSavingChanges,
|
|
aplicaciones: aplicaciones);
|
|
}
|
|
}
|