mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-23 03:02:51 +08:00

- 修改 连接池内部 Ping Timeout 值暂定 5秒; - 优化 初始化时若数据库超时,则放弃预热; - FreeSql.Repository 下增加 ISelect.FromRepository 扩展方法,实现分表的多表查询; - 增加 FreeSql.Repository Autofac 泛型注入,可利用实现全局过滤+分表分库; - 补充 GuidRepository 插入数据时,根据 filter 参数设定进行数据验证;
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FreeSql {
|
|
public class GuidRepository<TEntity> :
|
|
BaseRepository<TEntity, Guid>
|
|
where TEntity : class {
|
|
|
|
public GuidRepository(IFreeSql fsql) : this(fsql, null, null) {
|
|
|
|
}
|
|
public GuidRepository(IFreeSql fsql, Expression<Func<TEntity, bool>> filter, Func<string, string> asTable) : base(fsql, filter, asTable) {
|
|
}
|
|
|
|
public override List<TEntity> Insert(IEnumerable<TEntity> entity) {
|
|
base.ValidatorEntityAndThrow(entity);
|
|
_fsql.Insert<TEntity>().AppendData(entity).AsTable(AsTable).ExecuteAffrows();
|
|
return entity.ToList();
|
|
}
|
|
|
|
async public override Task<List<TEntity>> InsertAsync(IEnumerable<TEntity> entity) {
|
|
base.ValidatorEntityAndThrow(entity);
|
|
await _fsql.Insert<TEntity>().AppendData(entity).AsTable(AsTable).ExecuteAffrowsAsync();
|
|
return entity.ToList();
|
|
}
|
|
|
|
public override TEntity Insert(TEntity entity) {
|
|
base.ValidatorEntityAndThrow(entity);
|
|
_fsql.Insert<TEntity>().AppendData(entity).AsTable(AsTable).ExecuteAffrows();
|
|
return entity;
|
|
}
|
|
|
|
async public override Task<TEntity> InsertAsync(TEntity entity) {
|
|
base.ValidatorEntityAndThrow(entity);
|
|
await _fsql.Insert<TEntity>().AppendData(entity).AsTable(AsTable).ExecuteAffrowsAsync();
|
|
return entity;
|
|
}
|
|
}
|
|
}
|