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

如:var postRepos = fsql.GetGuidRepository<Post>(a => a.TopicId == 1); postRepos CURD 方法都会以 lambad 条件作为查询或验证,Update/Insert验证错误时会抛出异常。 - ISelect 增加 First/FirstAsync;
37 lines
1.0 KiB
C#
37 lines
1.0 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, Expression<Func<TEntity, bool>> filter) : base(fsql, filter) {
|
|
}
|
|
|
|
public override List<TEntity> Insert(IEnumerable<TEntity> entity) {
|
|
_fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrows();
|
|
return entity.ToList();
|
|
}
|
|
|
|
async public override Task<List<TEntity>> InsertAsync(IEnumerable<TEntity> entity) {
|
|
await _fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrowsAsync();
|
|
return entity.ToList();
|
|
}
|
|
|
|
public override TEntity Insert(TEntity entity) {
|
|
_fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrows();
|
|
return entity;
|
|
}
|
|
|
|
async public override Task<TEntity> InsertAsync(TEntity entity) {
|
|
await _fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrowsAsync();
|
|
return entity;
|
|
}
|
|
}
|
|
}
|