Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.ChangeTracking;
Expand Down Expand Up @@ -1919,6 +1920,31 @@ public virtual void Lazy_loading_finds_correct_entity_type_with_alternate_model(
}
}

[ConditionalFact]
public virtual void Top_level_projection_track_entities_before_passing_to_client_method()
{
using (var context = CreateContext(lazyLoadingEnabled: true))
{
var query = (from p in context.Set<Parent>()
select DtoFactory.CreateDto(p)).FirstOrDefault();

Assert.NotNull(((dynamic)query).Single);
}
}

private static class DtoFactory
{
public static object CreateDto(Parent parent)
{
return new
{
parent.Id,
parent.Single,
parent.Single.ParentId
};
}
}

public class Address
{
public int AddressId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,21 @@ public override async Task Load_collection(EntityState state, bool async)
}
}

[ConditionalFact(Skip = "Issue#1015")]
public override void Top_level_projection_track_entities_before_passing_to_client_method()
{
base.Top_level_projection_track_entities_before_passing_to_client_method();

Assert.Equal(
@"@__p_0='707' (Nullable = true)

SELECT [e].[Id], [e].[ParentId]
FROM [Child] AS [e]
WHERE [e].[ParentId] = @__p_0",
Sql,
ignoreLineEndingDifferences: true);
}

protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear();

protected override void RecordLog() => Sql = Fixture.TestSqlLoggerFactory.Sql;
Expand Down