Skip to content

Commit

Permalink
Merge branch 'release/6.3-preview8' into release/6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Aug 15, 2019
2 parents 77b7af9 + 2a28986 commit 54641fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/EntityFramework/Hierarchy/HierarchyId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public HierarchyId GetAncestor(int n)
{
return new HierarchyId(null);
}
else if (GetLevel() == n)
{
return new HierarchyId(PathSeparator);
}
string hierarchyStr = PathSeparator +
string.Join(PathSeparator, _nodes.Take(GetLevel() - n).Select(IntArrayToStirng))
+ PathSeparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void Check_hierarchyid_functions()
Assert.Equal(new HierarchyId("/1/2.1/3/").GetAncestor(2), new HierarchyId("/1/"));
Assert.Equal(new HierarchyId("/1/").GetAncestor(2) == null, true);
Assert.Equal(new HierarchyId("/1/").GetAncestor(2) == new HierarchyId(null), true);
Assert.Equal(new HierarchyId("/1/").GetAncestor(1), new HierarchyId("/"));
Assert.Equal(new HierarchyId("/1/").IsDescendantOf(null), true);
Assert.Equal(new HierarchyId("/1/").IsDescendantOf(new HierarchyId(null)), true);
Assert.Equal(new HierarchyId("/1/2/").IsDescendantOf(new HierarchyId("/")), true);
Expand Down

0 comments on commit 54641fb

Please sign in to comment.