mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
v0.1.5
- 增加 IsSyncStructureToUpper 参数,以便适应 Oracle 大小写使用习惯; - FreeSql.Repository 增加 GuidRepository 类,适用 Insert 方法无须返回插入的数据; - FreeSql.Repository 增加 IFreeSql 扩展方法 GetRepository、GetGuidRepository;
This commit is contained in:
14
FreeSql.Repository/DefaultRepository.cs
Normal file
14
FreeSql.Repository/DefaultRepository.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql {
|
||||
public class DefaultRepository<TEntity, TKey> :
|
||||
BaseRepository<TEntity, TKey>
|
||||
where TEntity : class {
|
||||
|
||||
public DefaultRepository(IFreeSql fsql) : base(fsql) {
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>0.1.4</Version>
|
||||
<Version>0.1.5</Version>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>FreeSql 通用仓库层现实,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||
|
34
FreeSql.Repository/GuidRepository.cs
Normal file
34
FreeSql.Repository/GuidRepository.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FreeSql {
|
||||
public class GuidRepository<TEntity> :
|
||||
BaseRepository<TEntity, Guid>
|
||||
where TEntity : class {
|
||||
|
||||
public GuidRepository(IFreeSql fsql) : base(fsql) {
|
||||
}
|
||||
|
||||
public override List<TEntity> Insert(List<TEntity> entity) {
|
||||
_fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrows();
|
||||
return entity;
|
||||
}
|
||||
|
||||
async public override Task<List<TEntity>> InsertAsync(List<TEntity> entity) {
|
||||
await _fsql.Insert<TEntity>().AppendData(entity).ExecuteAffrowsAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
30
FreeSql.Repository/IFreeSqlExtenssions.cs
Normal file
30
FreeSql.Repository/IFreeSqlExtenssions.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using FreeSql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public static class IFreeSqlExtenssions {
|
||||
|
||||
/// <summary>
|
||||
/// 返回默认仓库类
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <typeparam name="TKey"></typeparam>
|
||||
/// <param name="that"></param>
|
||||
/// <returns></returns>
|
||||
public static IRepository<TEntity, TKey> GetRepository<TEntity, TKey>(this IFreeSql that) where TEntity : class {
|
||||
|
||||
return new DefaultRepository<TEntity, TKey>(that);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回仓库类,适用 Insert 方法无须返回插入的数据
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <param name="that"></param>
|
||||
/// <returns></returns>
|
||||
public static IRepository<TEntity, Guid> GetGuidRepository<TEntity>(this IFreeSql that) where TEntity : class {
|
||||
|
||||
return new GuidRepository<TEntity>(that);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user