- 修复 IncludeMany 只填充子属性中双向关系的 ManyToOne 对象值;

This commit is contained in:
28810 2020-06-11 00:06:53 +08:00
parent c4ec130451
commit a76ae83eab
3 changed files with 4 additions and 1 deletions

View File

@ -9,6 +9,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>FreeSql.Tests.xml</DocumentationFile> <DocumentationFile>FreeSql.Tests.xml</DocumentationFile>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -42,6 +42,7 @@ namespace FreeSql.Tests.Linq
[Fact] [Fact]
public void RestoreToSelect() public void RestoreToSelect()
{ {
fsql.Insert(new qt01[] { new qt01 { name = "001" }, new qt01 { name = "001" } }).ExecuteAffrows();
Assert.Equal(fsql.Select<qt01>().Skip(2).First(a => a.name), fsql.Select<qt01>().AsQueryable().Skip(2).Take(1).RestoreToSelect().First(a => a.name)); Assert.Equal(fsql.Select<qt01>().Skip(2).First(a => a.name), fsql.Select<qt01>().AsQueryable().Skip(2).Take(1).RestoreToSelect().First(a => a.name));
Assert.Equal(fsql.Select<qt01>().Skip(2).First(a => new { a.name }).name, fsql.Select<qt01>().AsQueryable().Skip(2).Take(1).RestoreToSelect().First(a => new { a.name }).name); Assert.Equal(fsql.Select<qt01>().Skip(2).First(a => new { a.name }).name, fsql.Select<qt01>().AsQueryable().Skip(2).Take(1).RestoreToSelect().First(a => new { a.name }).name);
} }

View File

@ -637,7 +637,7 @@ namespace FreeSql.Internal.CommonProvider
if (tr2ref == null) continue; if (tr2ref == null) continue;
if (tr2ref.RefType != TableRefType.ManyToOne) continue; if (tr2ref.RefType != TableRefType.ManyToOne) continue;
if (tr2ref.RefEntityType != tb.Type) continue; if (tr2ref.RefEntityType != tb.Type) continue;
if (string.Join(",", tr2ref.Columns.Select(a => a.CsName).OrderBy(a => a)) != string.Join(",", tbref.RefColumns.Select(a => a.CsName).OrderBy(a => a))) continue; //防止把 ManyToOne 多个相同类型的导航属性值都填充了 if (string.Join(",", tr2ref.Columns.Select(a => a.CsName).OrderBy(a => a)) != string.Join(",", tbref.RefColumns.Select(a => a.CsName).OrderBy(a => a))) continue; //- 修复 IncludeMany 只填充子属性中双向关系的 ManyToOne 对象值;防止把 ManyToOne 多个相同类型的导航属性值都填充了
parentNavs.Add(navProp.Key); parentNavs.Add(navProp.Key);
} }
foreach (var nav in subList) foreach (var nav in subList)