mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 修复 延时属性时级联保存失败的 bug;
This commit is contained in:
parent
45c98cb299
commit
2401f7a9e3
@ -512,14 +512,5 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -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 = "分类1",
|
||||
Goodss = new List<GoodsLD>(new[]
|
||||
{
|
||||
new GoodsLD { Name = "商品1" },
|
||||
new GoodsLD { Name = "商品2" },
|
||||
new GoodsLD { Name = "商品3" }
|
||||
})
|
||||
},
|
||||
new CagetoryLD
|
||||
{
|
||||
Name = "分类2",
|
||||
Goodss = new List<GoodsLD>(new[]
|
||||
{
|
||||
new GoodsLD { Name = "商品4" },
|
||||
new GoodsLD { Name = "商品5" }
|
||||
})
|
||||
}
|
||||
};
|
||||
repo.Insert(cts);
|
||||
cts[0].Name = "分类11";
|
||||
cts[0].Goodss.Clear();
|
||||
cts[1].Name = "分类22";
|
||||
cts[1].Goodss.Clear();
|
||||
repo.Update(cts);
|
||||
cts[0].Name = "分类111";
|
||||
cts[0].Goodss.Clear();
|
||||
cts[0].Goodss.Add(new GoodsLD { Name = "商品33" });
|
||||
cts[1].Name = "分类222";
|
||||
cts[1].Goodss.Clear();
|
||||
cts[1].Goodss.Add(new GoodsLD { Name = "商品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()
|
||||
{
|
||||
|
15
FreeSql.sln
15
FreeSql.sln
@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.KingbaseES
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Firebird", "Providers\FreeSql.Provider.Firebird\FreeSql.Provider.Firebird.csproj", "{101B11D2-7780-4E14-9B72-77F5D69B3DF9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.ElasticsearchSQL", "Providers\FreeSql.Provider.ElasticsearchSQL\FreeSql.Provider.ElasticsearchSQL.csproj", "{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -557,6 +559,18 @@ Global
|
||||
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{101B11D2-7780-4E14-9B72-77F5D69B3DF9}.Release|x86.Build.0 = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -589,6 +603,7 @@ Global
|
||||
{3D2BD8EC-253A-437F-B4C8-74BC0D91429B} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{CDD6A896-F6DF-44CB-B430-06B383916EB0} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{101B11D2-7780-4E14-9B72-77F5D69B3DF9} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
{EC6980FD-090D-4BAA-8421-0D4C3D306F0D} = {2A381C57-2697-427B-9F10-55DA11FD02E4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
|
||||
|
@ -925,6 +925,7 @@ namespace FreeSql.Internal
|
||||
{ //set 重写
|
||||
cscode.Append(" ").Append(propSetModification).Append(" set {\r\n")
|
||||
.Append(" base.").Append(pnv.Name).AppendLine(" = value;")
|
||||
.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;")
|
||||
.Append(" }\r\n");
|
||||
}
|
||||
cscode.AppendLine(" }");
|
||||
@ -1050,9 +1051,9 @@ namespace FreeSql.Internal
|
||||
if (refprop != null)
|
||||
{
|
||||
cscode.Append(" foreach (var loc1 in base.").Append(pnv.Name).AppendLine(")")
|
||||
.Append(" loc1.").Append(refprop.Name).AppendLine(" = this;")
|
||||
.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;");
|
||||
.Append(" loc1.").Append(refprop.Name).AppendLine(" = this;");
|
||||
}
|
||||
cscode.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;");
|
||||
}
|
||||
else
|
||||
cscode.Append(" throw new Exception(\"").Append(nvref.Exception.Message.Replace("\r\n", "\\r\\n").Replace("\"", "\\\"")).AppendLine("\");");
|
||||
@ -1066,6 +1067,7 @@ namespace FreeSql.Internal
|
||||
{ //set 重写
|
||||
cscode.Append(" ").Append(propSetModification).Append(" set {\r\n")
|
||||
.Append(" base.").Append(pnv.Name).AppendLine(" = value;")
|
||||
.Append(" __lazy__").Append(pnv.Name).AppendLine(" = true;")
|
||||
.Append(" }\r\n");
|
||||
}
|
||||
cscode.AppendLine(" }");
|
||||
|
Loading…
x
Reference in New Issue
Block a user