public class BaseRepository<T, TS> where T : class where TS : DbContext, new()
{
//当前操作数据库的实例
private DbContext db = DbContextFactory<TS>.GetCurrentDbContext();
/// <summary>
/// 单表的添加一条记录
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool Add(T entity)
{
//将实例添加到上下文中
db.Set<T>().Add(entity);
//保存更改
return db.SaveChanges() > 0;
}
/// <summary>
/// 单表的添加多条记录
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public bool AddRange(List<T> entities)
{