public class Category : BaseModel
{
[Required] public string Name { get; set; }
public int? ParentId { get; set; }
public virtual Category Parent { get; set; }
public virtual ICollection<Category> Children { get; set; }
public virtual ICollection<Product> Products { get; set; }
public override string ToString() => $"{Name} - {(ParentId == null ? "root" : "child")}";
}
Currently, navigation properties Children and Products cause the code to crash.
After inspecting the code I found that there is no support for rendering such properties.
So, I made the controller eager load the entities before sending them to the View to avoid the crash, then I added code in the view that should render these properties as <ul>
Consider the following case
Currently, navigation properties
Children
andProducts
cause the code to crash. After inspecting the code I found that there is no support for rendering such properties. So, I made the controller eager load the entities before sending them to the View to avoid the crash, then I added code in the view that should render these properties as<ul>