snickler / EFCore-FluentStoredProcedure

EFCore Extension that allows a means to map a stored procedure to a class, fluently.
MIT License
177 stars 34 forks source link

Hierarchies using EFCore-FluentStoredProcedure #39

Closed mkojoa closed 3 years ago

mkojoa commented 3 years ago
public class Parent
{
    public Guid Id { get; set; }
    public IEnumerable<Child> Children { get; set; }
}
public class Child
{
    public Guid ParentId { get; set; }
}

I have a parent menu and child menus. Using `EFCore-FluentStoredProcedure` How do i produce the following?

```yaml
{
  "Hospitals": [
    {
      "37 Military": {
        "Apps": [
          {
            "Name": "Global",
            "Menu-0": [
              {
                "Name": "General",
                "Menu-1": [
                  {
                    "Name": "Staff Attandance",
                    "Menu-2": [
                      {
                        "Name": "Clock-In"
                      },
                      {
                        "Name": "Clock-Out"
                      }
                    ]
                  },
                  {
                    "Name": "Pesonal Account",
                    "Menu-2": [
                      {
                        "Name": "View",
                        "Menu-3": [
                          {
                            "Name": "Hours Worked"
                          },
                          {
                            "Name": "Lateness Report"
                          },
                          {
                            "Name": "Overtime"
                          },
                          {
                            "Name": "My PaySlip"
                          },
                          {
                            "Name": "E-Notice Board"
                          },
                          {
                            "Name": "My Meno"
                          },
                          {
                            "Name": "My Voucher Request Status"
                          },
                          {
                            "Name": "My PLT Request Status"
                          },
                          {
                            "Name": "My Stock Request Status"
                          }
                        ]
                      },
                      {
                        "Name": "Request",
                        "Menu-3": [
                          {
                            "Name": "Request for Petty Cash"
                          },
                          {
                            "Name": "Request from General Store"
                          },
                          {
                            "Name": "Request for PLT"
                          },
                          {
                            "Name": "Request for Salary Advance"
                          }
                        ]
                      },
                      {
                        "Name": "Send",
                        "Menu-3": [
                          {
                            "Name": "Send Memo"
                          },
                          {
                            "Name": "Send Suggestion Box"
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "Name": "Theme",
                    "Menu-2": [
                      {
                        "Name": "Default"
                      },
                      {
                        "Name": "Dark"
                      },
                      {
                        "Name": "Blue"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      "Zion Hospital":{
      }
    }
  ]
}
mooshpot commented 3 years ago

Hi mkojoa

I hope you're well.

You'd need to do this at the database end of things. Here are some examples: https://tapoueh.org/blog/2018/01/exporting-a-hierarchy-in-json-with-recursive-queries/ https://stackoverflow.com/questions/38298659/how-to-generate-hierarchical-json-data-with-microsoft-sql-server-2016/41823306

Cheers Moosh

mkojoa commented 3 years ago

Yes, i am doing great. Thanks for the help.