Unable to query all hierarchy levels
See original GitHub issueUnable to query all hierarchy levels
Steps to reproduce
public class Permission
{
public Permission()
{
ChildPermissions = new HashSet<Permission>();
}
public int PermissionID { get; set; }
public string PermissionName { get; set; }
public int? ParentPermissionID { get; set; }
public virtual Permission ParentPermission { get; set; }
public virtual ICollection<Permission> ChildPermissions { get; }
}
var permissionList = new Permission[] {
new Permission
{
PermissionID = 1,
PermissionName = "1"
},
new Permission
{
PermissionID = 2,
PermissionName = "1.1",
ParentPermissionID = 1
},
new Permission
{
PermissionID = 3,
PermissionName = "1.2",
ParentPermissionID = 1
},
new Permission
{
PermissionID = 4,
PermissionName = "1.1.1",
ParentPermissionID = 2
},
new Permission
{
PermissionID = 5,
PermissionName = "1.1.2",
ParentPermissionID = 2
}
};
_Context.Permission.Include(x => x.ChildPermissions)
.AsEnumerable()
.Where(x => x.ParentPermissionID == null)
.ToList();
The result doesn’t include third level “1.1.1” & “1.1.2” Generated query only shows left join
Further technical details
EF Core version: 3.0 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET Core 3.0) Operating system: IDE: (e.g. Visual Studio 2019 16.3)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
sql - Query with hierarchical structure and variable number ...
Query with hierarchical structure and variable number of hierarchy levels. Areas are organized in hierarchy up to four levels using PARENT_ID ...
Read more >Unable to select highest hierarchy date in bar chart visual
Solved: Hi, Has anyone come across the situation where you have a normal bar chart with date heirarchy along X and values up...
Read more >Can't create a filter on a deep node in hierarchy in BW Query
I'm createing a BW query in a BW/4HANA system, I want to filter by a specific node of a hierarchy, but at certain...
Read more >Unable to get the idea of hierarchy query
Hi Every oneI'm trying to learn oracle hierarchy query and spent couples of hours but ... select grp, effective_date, termination_date,level.
Read more >Hierarchical Data Queries: Iteration Limits No Longer ...
When querying hierarchical data, you can use recursive CTEs or the CONNECT BY command to iterate over each level of hierarchy.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@NanFengCheong I am not able to reproduce this–see my code below. Please post a small, runnable project/solution or complete code listing, like below, that demonstrates the behavior you are seeing.
My bad. There is a library turn off following setting causing unexpected behavior.