- 修复 延时属性时级联保存失败的 bug;

This commit is contained in:
2881099
2020-12-11 18:48:28 +08:00
parent 45c98cb299
commit 2401f7a9e3
4 changed files with 91 additions and 11 deletions

View File

@ -253,6 +253,8 @@ namespace FreeSql.Tests
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
cts2[0].Goodss[0].Name += 123;
repo.Update(cts2[0]);
cts2[0].Goodss[0].Name += 333;
repo.SaveMany(cts2[0], "Goodss");
}
[Table(Name = "EAUNL_OTM_CT")]
class Cagetory
@ -270,6 +272,76 @@ namespace FreeSql.Tests
public Guid CagetoryId { get; set; }
public string Name { get; set; }
}
[Fact]
public void EnableAddOrUpdateNavigateList_OneToMany_lazyloading()
{
var repo = g.sqlite.GetRepository<CagetoryLD>();
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true;
var cts = new[] {
new CagetoryLD
{
Name = "<22><><EFBFBD><EFBFBD>1",
Goodss = new List<GoodsLD>(new[]
{
new GoodsLD { Name = "<22><>Ʒ1" },
new GoodsLD { Name = "<22><>Ʒ2" },
new GoodsLD { Name = "<22><>Ʒ3" }
})
},
new CagetoryLD
{
Name = "<22><><EFBFBD><EFBFBD>2",
Goodss = new List<GoodsLD>(new[]
{
new GoodsLD { Name = "<22><>Ʒ4" },
new GoodsLD { Name = "<22><>Ʒ5" }
})
}
};
repo.Insert(cts);
cts[0].Name = "<22><><EFBFBD><EFBFBD>11";
cts[0].Goodss.Clear();
cts[1].Name = "<22><><EFBFBD><EFBFBD>22";
cts[1].Goodss.Clear();
repo.Update(cts);
cts[0].Name = "<22><><EFBFBD><EFBFBD>111";
cts[0].Goodss.Clear();
cts[0].Goodss.Add(new GoodsLD { Name = "<22><>Ʒ33" });
cts[1].Name = "<22><><EFBFBD><EFBFBD>222";
cts[1].Goodss.Clear();
cts[1].Goodss.Add(new GoodsLD { Name = "<22><>Ʒ55" });
repo.Update(cts);
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
cts2[0].Goodss[0].Name += 123;
repo.Update(cts2[0]);
cts2[0].Goodss[0].Name += 333;
repo.SaveMany(cts2[0], "Goodss");
cts2 = repo.Select.WhereDynamic(cts).ToList();
cts2[0].Goodss[0].Name += 123;
repo.Update(cts2[0]);
cts2[0].Goodss[0].Name += 333;
repo.SaveMany(cts2[0], "Goodss");
}
[Table(Name = "EAUNL_OTM_CTLD")]
public class CagetoryLD
{
public Guid Id { get; set; }
public string Name { get; set; }
[Navigate("CagetoryId")]
public virtual List<GoodsLD> Goodss { get; set; }
}
[Table(Name = "EAUNL_OTM_GDLD")]
public class GoodsLD
{
public Guid Id { get; set; }
public Guid CagetoryId { get; set; }
public string Name { get; set; }
}
[Fact]
public void SaveMany_OneToMany()
{