-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
37 lines (32 loc) · 1007 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using EFCore.ProjectionOnNestedReference;
using EFCore.ProjectionOnNestedReference.Data;
using Context context = new();
await context.Database.EnsureCreatedAsync();
try
{
_ = context.Customers
.Select(m => new CustomerDto()
{
Id = m.Id,
CompanyId = m.CompanyId,
Company = m.Company != null ? new CompanyDto()
{
Id = m.Company.Id,
CompanyName = m.Company.CompanyName,
CountryId = m.Company.CountryId,
Country = new CountryDto()
{
Id = m.Company.Country.Id,
CountryName = m.Company.Country.CountryName,
},
} : null,
})
//.Where(m => m.Company!.CompanyName == "COMPANY") // It works
.Where(m => m.Company!.Country!.CountryName == "COUNTRY") // It fails
.ToArray();
Console.WriteLine("It works");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}