using FreeSql;
using System;
using System.Linq.Expressions;
using System.Linq;
public static class FreeSqlRepositoryExtensions
{
///
/// 返回默认仓库类
///
///
///
///
/// 数据过滤 + 验证
///
public static DefaultRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class
{
return new DefaultRepository(that, filter);
}
///
/// 返回默认仓库类,适用联合主键的仓储类
///
///
///
/// 数据过滤 + 验证
///
public static BaseRepository GetRepository(this IFreeSql that, Expression> filter = null) where TEntity : class
{
return new DefaultRepository(that, filter);
}
///
/// 返回仓库类
///
///
///
/// 数据过滤 + 验证
/// 分表规则,参数:旧表名;返回:新表名 https://github.com/2881099/FreeSql/wiki/Repository
///
public static GuidRepository GetGuidRepository(this IFreeSql that, Expression> filter = null, Func asTable = null) where TEntity : class
{
return new GuidRepository(that, filter, asTable);
}
/////
///// 合并两个仓储的设置(过滤+分表),以便查询
/////
/////
/////
/////
/////
/////
//public static ISelect FromRepository(this ISelect that, BaseRepository repos) where TEntity : class where T2 : class
//{
// var filters = (repos.DataFilter as DataFilter)._filters.Where(a => a.Value.IsEnabled == true);
// foreach (var filter in filters) that.Where(filter.Value.Expression);
// return that.AsTable(repos.AsTableSelectInternal);
//}
///
/// 创建基于仓储功能的工作单元,务必使用 using 包含使用
///
///
///
public static IRepositoryUnitOfWork CreateUnitOfWork(this IFreeSql that)
{
return new RepositoryUnitOfWork(that);
}
}