using System;
using VT.FW.DB;
namespace Edu.Repository
{
///
/// 仓储层基类
///
/// 约束实体
public class BaseRepository : RepositoryBase where T : class
{
///
/// 数据库连接Key
///
public string ConnKey { get; set; }
public BaseRepository()
{
string connKey;
try
{
var classAttribute = (DBAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DBAttribute));
connKey = classAttribute.ConnectionName ?? "DefaultConnection";
}
catch (Exception ex)
{
throw ex;
}
ConnKey = connKey ?? throw new ArgumentNullException(nameof(connKey));
}
public string _ConnectionStr;
///
/// 链接字符串
///
public override string ConnectionStr
{
get
{
_ConnectionStr =Common.Config.GetConnectionString(ConnKey);
return _ConnectionStr;
}
set
{
_ConnectionStr = value;
}
}
public string _ProviderName;
///
/// 提供程序名称
///
public override string ProviderName
{
get
{
_ProviderName = "MySql.Data.MySqlClient";
return _ProviderName;
}
set
{
_ProviderName = value;
}
}
}
}