34 lines
754 B
C#
34 lines
754 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using AyCode.Database.DbContexts;
|
|
using AyCode.Utils.Extensions;
|
|
|
|
namespace AyCode.Database;
|
|
|
|
public class DalBase<TDbContext> where TDbContext : DbContextBase
|
|
{
|
|
public string Name { get; private set; }
|
|
private TDbContext _ctx;
|
|
public TDbContext Ctx => _ctx;
|
|
|
|
public DalBase() : this(Activator.CreateInstance<TDbContext>())
|
|
{ }
|
|
|
|
public DalBase(TDbContext ctx)
|
|
{
|
|
_ctx = ctx;
|
|
|
|
if (_ctx.Name.IsNullOrWhiteSpace())
|
|
_ctx.Name = _ctx.GetType().Name;
|
|
|
|
Name = $"{this.GetType().Name}, {_ctx.Name}";
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Name;
|
|
}
|
|
} |