We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http://pastebin.com/mXCLp8du
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using Microsoft.EntityFrameworkCore; namespace EFBug { public class Program { public static void Main(string[] args) { using (var db = new TestContext()) { db.Parent.Add(new Parent { Child = new Child() {ChildData = "Childtest"} }); var count = db.SaveChanges(); string data1 = db.Parent.Select(x => x.Child.ChildData).First(); //Query is //SELECT TOP(1) [x.Child].[ChildData] //FROM [Parent] AS[x] //INNER JOIN [Child] AS[x.Child] ON[x].[ChildId] = [x.Child].[Id] string data2 = db.Parent.Select(x => x.NullableChild.ChildData).First(); //Query is //SELECT [x].[Id], [x].[ChildId], [x].[NullableChildId], [x.NullableChild].[Id], [x.NullableChild].[ChildData], [x.NullableChild].[ChildData1], [x.NullableChild].[ChildData2], [x.NullableChild].[ChildData3] //FROM [Parent] AS[x] //LEFT JOIN [Child] AS[x.NullableChild] ON[x].[NullableChildId] = [x.NullableChild].[Id] //ORDER BY [x].[NullableChildId] } } } public class TestContext : DbContext { public DbSet<Parent> Parent { get; set; } public DbSet<Child> Child { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFBug;Trusted_Connection=True;"); } } public class Parent { public Parent() {} [Key] public int Id { get; set; } [ForeignKey("NullableChild")] public int? NullableChildId { get; set; } public Child NullableChild { get; set; } [ForeignKey("Child")] public int ChildId { get; set; } public Child Child { get; set; } } public class Child { public Child(){} [Key] public int Id { get; set; } public string ChildData { get; set; } public string ChildData1 { get; set; } public string ChildData2 { get; set; } public string ChildData3 { get; set; } } }
When selecting a single column from a Nullable child Entity, the whole Object is selected rather than a single property. See code above.
string data1 = db.Parent.Select(x => x.Child.ChildData).First(); //Query is //SELECT TOP(1) [x.Child].[ChildData] //FROM [Parent] AS[x] //INNER JOIN [Child] AS[x.Child] ON[x].[ChildId] = [x.Child].[Id] string data2 = db.Parent.Select(x => x.NullableChild.ChildData).First(); //Query is //SELECT [x].[Id], [x].[ChildId], [x].[NullableChildId], [x.NullableChild].[Id], [x.NullableChild].[ChildData], [x.NullableChild].[ChildData1], [x.NullableChild].[ChildData2], [x.NullableChild].[ChildData3] //FROM [Parent] AS[x] //LEFT JOIN [Child] AS[x.NullableChild] ON[x].[NullableChildId] = [x.NullableChild].[Id] //ORDER BY [x].[NullableChildId]
EF Core version: 1.0.0 Operating system: Windows 10 Visual Studio version: (e.g. VS 2013 or n/a) Visual Studio 2015
Other details about my project setup:
The text was updated successfully, but these errors were encountered:
dupe of #4588
Sorry, something went wrong.
No branches or pull requests
Steps to reproduce
http://pastebin.com/mXCLp8du
The issue
When selecting a single column from a Nullable child Entity, the whole Object is selected rather than a single property. See code above.
Further technical details
EF Core version: 1.0.0
Operating system: Windows 10
Visual Studio version: (e.g. VS 2013 or n/a) Visual Studio 2015
Other details about my project setup:
The text was updated successfully, but these errors were encountered: