Files
AlquilaFacil/Modelo/RepositorioBase.cs

28 lines
696 B
C#

using System.Collections.ObjectModel;
using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo;
public abstract class RepositorioBase<S>
where S : new()
{
protected AlquilaFacilContext Context { get{ return new AlquilaFacilContext();}}
private static readonly S instance = new();
public static S Singleton { get{return instance;}}
public bool Guardar(AlquilaFacilContext context){
bool ret = false;
try
{
context.SaveChanges();
context.Dispose();
ret = true;
} catch (DbUpdateException ex)
{
Console.Error.WriteLine(ex.Message);
}
return ret;
}
}