From eb8c2defec2a3259e8a83f1da32b8ab364c15ee8 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Mon, 15 Aug 2022 22:05:16 +0800 Subject: [PATCH] 1 --- Repository-Layer.md | 20 ++++++++++---------- Repository.md | 19 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Repository-Layer.md b/Repository-Layer.md index ab6cff3..eb19398 100644 --- a/Repository-Layer.md +++ b/Repository-Layer.md @@ -31,7 +31,8 @@ static IFreeSql fsql = new FreeSql.FreeSqlBuilder() //Be sure to define as singleton mode .Build(); -public class Song { +public class Song +{ [Column(IsIdentity = true)] public int Id { get; set; } public string Title { get; set; } @@ -52,7 +53,8 @@ var curd = fsql.GetRepository(); Method 2. Inheritance ```csharp -public class SongRepository : BaseRepository { +public class SongRepository : BaseRepository +{ public SongRepository(IFreeSql fsql) : base(fsql, null, null) {} //Do something except CURD. @@ -62,19 +64,16 @@ public class SongRepository : BaseRepository { Method 3: Dependency Injection ```csharp -public void ConfigureServices(IServiceCollection services) { +public void ConfigureServices(IServiceCollection services) +{ services.AddSingleton(Fsql); - services.AddFreeRepository(filter => filter - .Apply("SoftDelete", a => a.IsDeleted == false) - .Apply("Tenant", a => a.TenantId == 1) - , - this.GetType().Assembly - ); + services.AddFreeRepository(null, this.GetType().Assembly); } //Use in the controller -public SongsController(IBaseRepository repos1) { +public SongsController(IBaseRepository songRepository) +{ } ``` @@ -176,6 +175,7 @@ Please view the documentation of [Cascade Saving](Cascade-Saving). | Orm | IFreeSql | ORM currently in use | | DbContextOptions | DbContextOptions | DbContext settings currently in use,modifying the DbContextOptions will not affect other repository. | | DataFilter | IDataFilter\ | Repository Filter, valid in this object | +| UpdateDiy | IUpdate\| Prepare update, same transaction as warehousing | | Select | ISelect\ | Prepare to query data | | Method | Return | Parameter | Description | diff --git a/Repository.md b/Repository.md index 20bd459..faa5367 100644 --- a/Repository.md +++ b/Repository.md @@ -29,7 +29,8 @@ static IFreeSql fsql = new FreeSql.FreeSqlBuilder() .UseAutoSyncStructure(true) //自动迁移实体的结构到数据库 .Build(); //请务必定义成 Singleton 单例模式 -public class Song { +public class Song +{ [Column(IsIdentity = true)] public int Id { get; set; } public string Title { get; set; } @@ -50,7 +51,8 @@ var curd = fsql.GetRepository(); 方法2、继承实现; ```csharp -public class SongRepository : BaseRepository { +public class SongRepository : BaseRepository +{ public SongRepository(IFreeSql fsql) : base(fsql, null, null) {} //在这里增加 CURD 以外的方法 @@ -60,19 +62,16 @@ public class SongRepository : BaseRepository { 方法3、依赖注入; ```csharp -public void ConfigureServices(IServiceCollection services) { +public void ConfigureServices(IServiceCollection services) +{ services.AddSingleton(Fsql); - services.AddFreeRepository(filter => filter - .Apply("SoftDelete", a => a.IsDeleted == false) - .Apply("Tenant", a => a.TenantId == 1) - , - this.GetType().Assembly - ); + services.AddFreeRepository(null, this.GetType().Assembly); } //在控制器使用 -public SongsController(IBaseRepository repos1) { +public SongsController(IBaseRepository songRepository) +{ } ```