mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-04 23:40:53 +08:00
update
@@ -20,7 +20,7 @@ Method 2: Additional save, do not delete the existing data in the table
|
||||
|
||||
```csharp
|
||||
var repo = fsql.GetRepository<T>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //Need to be opened manually
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true; //Need to be opened manually
|
||||
repo.Insert(item);
|
||||
```
|
||||
- Do not delete the existing data in the table, confirm?
|
||||
@@ -35,7 +35,7 @@ repo.Insert(item);
|
||||
|
||||
There is only one mechanism: complete preservation.
|
||||
|
||||
> Enabling the `EnableAddOrUpdateNavigateList` option or `SaveMany` is a complete save.
|
||||
> Enabling the `EnableAddOrUpdateNavigate` option or `SaveMany` is a complete save.
|
||||
|
||||
---
|
||||
|
||||
@@ -53,9 +53,9 @@ class CagetoryParent {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnableAddOrUpdateNavigateList_OneToMany_Parent() {
|
||||
public void EnableAddOrUpdateNavigate_OneToMany_Parent() {
|
||||
var repo = fsql.GetRepository<CagetoryParent>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
var cts = new[] {
|
||||
new CagetoryParent
|
||||
{
|
||||
@@ -130,7 +130,7 @@ class SongTag {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnableAddOrUpdateNavigateList_ManyToMany() {
|
||||
public void EnableAddOrUpdateNavigate_ManyToMany() {
|
||||
var tags = new[] {
|
||||
new Tag { TagName = "Pop" },
|
||||
new Tag { TagName = "Modern music" },
|
||||
@@ -157,7 +157,7 @@ public void EnableAddOrUpdateNavigateList_ManyToMany() {
|
||||
}
|
||||
};
|
||||
var repo = fsql.GetRepository<Song>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
repo.Insert(ss);
|
||||
//INSERT INTO "EAUNL_MTM_SONG"("Id", "Name") VALUES('5d90fdb3-6a6b-2c58-00c8-37974177440d', 'Take Me To Your Heart.mp3'), ('5d90fdb3-6a6b-2c58-00c8-37987f29b197', 'Kiss Me More.mp3')
|
||||
//INSERT INTO "EAUNL_MTM_TAG"("Id", "TagName") VALUES('5d90fdb7-6a6b-2c58-00c8-37991ead4f05', 'Pop'), ('5d90fdbd-6a6b-2c58-00c8-379a0432a09c', 'Modern music')
|
||||
|
||||
@@ -45,7 +45,7 @@ To define the Childs property, you can also use [Cascade Saving](Cascade-Saving)
|
||||
```csharp
|
||||
fsql.Delete<Area>().Where("1=1").ExecuteAffrows();
|
||||
var repo = fsql.GetRepository<Area>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
repo.DbContextOptions.NoneParameter = true;
|
||||
repo.Insert(new Area
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ fsql.Select<Area>().Where(a => a.Childs.Any(c => c.Name == "北京")).First();
|
||||
```csharp
|
||||
fsql.Delete<Area>().Where("1=1").ExecuteAffrows();
|
||||
var repo = fsql.GetRepository<Area>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
repo.DbContextOptions.NoneParameter = true;
|
||||
repo.Insert(new Area
|
||||
{
|
||||
|
||||
12
联级保存.md
12
联级保存.md
@@ -20,7 +20,7 @@ repo.SaveMany(item, "Childs");
|
||||
|
||||
```csharp
|
||||
var repo = fsql.GetRepository<T>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //需要手工开启
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true; //需要手工开启
|
||||
repo.Insert(item);
|
||||
```
|
||||
- 不删除表已存在的数据,确认?
|
||||
@@ -35,7 +35,7 @@ repo.Insert(item);
|
||||
|
||||
只有一种机制:完整保存。
|
||||
|
||||
> 开启 EnableAddOrUpdateNavigateList 或者 SaveMany 都是完整保存。
|
||||
> 开启 EnableAddOrUpdateNavigate 或者 SaveMany 都是完整保存。
|
||||
|
||||
---
|
||||
|
||||
@@ -53,9 +53,9 @@ class CagetoryParent {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnableAddOrUpdateNavigateList_OneToMany_Parent() {
|
||||
public void EnableAddOrUpdateNavigate_OneToMany_Parent() {
|
||||
var repo = fsql.GetRepository<CagetoryParent>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
var cts = new[] {
|
||||
new CagetoryParent
|
||||
{
|
||||
@@ -130,7 +130,7 @@ class SongTag {
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnableAddOrUpdateNavigateList_ManyToMany() {
|
||||
public void EnableAddOrUpdateNavigate_ManyToMany() {
|
||||
var tags = new[] {
|
||||
new Tag { TagName = "流行" },
|
||||
new Tag { TagName = "80后" },
|
||||
@@ -157,7 +157,7 @@ public void EnableAddOrUpdateNavigateList_ManyToMany() {
|
||||
}
|
||||
};
|
||||
var repo = fsql.GetRepository<Song>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = true;
|
||||
repo.Insert(ss);
|
||||
//INSERT INTO "EAUNL_MTM_SONG"("Id", "Name") VALUES('5d90fdb3-6a6b-2c58-00c8-37974177440d', '爱你一万年.mp3'), ('5d90fdb3-6a6b-2c58-00c8-37987f29b197', '李白.mp3')
|
||||
//INSERT INTO "EAUNL_MTM_TAG"("Id", "TagName") VALUES('5d90fdb7-6a6b-2c58-00c8-37991ead4f05', '流行'), ('5d90fdbd-6a6b-2c58-00c8-379a0432a09c', '80后')
|
||||
|
||||
4
骚操作.md
4
骚操作.md
@@ -284,13 +284,13 @@ FreeSql.DbContext 和 仓储实现,已经实现了联级保存功能,联级
|
||||
全局关闭:
|
||||
|
||||
```csharp
|
||||
fsql.SetDbContextOptions(opt => opt.EnableAddOrUpdateNavigateList = false);
|
||||
fsql.SetDbContextOptions(opt => opt.EnableAddOrUpdateNavigate = false);
|
||||
```
|
||||
|
||||
局部关闭:
|
||||
```csharp
|
||||
var repo = fsql.GetRepository<T>();
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = false;
|
||||
repo.DbContextOptions.EnableAddOrUpdateNavigate = false;
|
||||
```
|
||||
|
||||
### 本功能:
|
||||
|
||||
Reference in New Issue
Block a user