CaptainSh4dow
CaptainSh4dow
CC#
Created by CaptainSh4dow on 9/26/2023 in #help
❔ [EFCore] What is the right approach to generate hierarchy id for new child entity?
my current approach that does two queries
public static HierarchyId GeneratePathForChild(HierarchyId? parent, HierarchyId? lastChildId)
{

//Handling Fatherless Entities.
if (parent is null)
return HierarchyId.Parse("/");

//Handling Entities With No Sister Entities.
if (lastChildId is null)
return HierarchyId.Parse($"{parent}{1}/");

//Handling Entities With Sister Entities
var lastDigit = lastChildId.ToString().Split("/", StringSplitOptions.RemoveEmptyEntries).Last();
var lastDigitNumber = int.Parse(lastDigit);
return HierarchyId.Parse($"{parent}{lastDigitNumber + 1}/");

}
public static HierarchyId GeneratePathForChild(HierarchyId? parent, HierarchyId? lastChildId)
{

//Handling Fatherless Entities.
if (parent is null)
return HierarchyId.Parse("/");

//Handling Entities With No Sister Entities.
if (lastChildId is null)
return HierarchyId.Parse($"{parent}{1}/");

//Handling Entities With Sister Entities
var lastDigit = lastChildId.ToString().Split("/", StringSplitOptions.RemoveEmptyEntries).Last();
var lastDigitNumber = int.Parse(lastDigit);
return HierarchyId.Parse($"{parent}{lastDigitNumber + 1}/");

}
one query to load the parent. and the other to load the last child.
5 replies
CC#
Created by CaptainSh4dow on 9/26/2023 in #help
❔ [EFCore] What is the right approach to generate hierarchy id for new child entity?
No description
5 replies
CC#
Created by Félix An on 2/23/2023 in #help
❔ How do I process a Alipay or WeChat Pay payment QR code (I scan the customer's payment code)...
what their docs says?
10 replies
CC#
Created by CaptainSh4dow on 2/15/2023 in #help
Difference between mapping controller directly with app.MapControllers & in app.UseEndpoint method ?
Understandable. thanks again.
9 replies
CC#
Created by CaptainSh4dow on 2/15/2023 in #help
Difference between mapping controller directly with app.MapControllers & in app.UseEndpoint method ?
Thank you for the clarification. i have tried searching for the documentations for that nuget package but ended up with nothing for some reason.
9 replies