Blazor how to create objects with large quantities of navigational properties?



  • The question is: https://pastebin.com/HAVRWqUW
    How is it right to order (MAOrder) from UI? All other classes (Status, category, etc.) are also stored in the database, so they need to be removed from the base, too.
    I tried to break each class into a separate component (in the example of status) so that it could be placed on the page (creation and editing), but it didn't work very well:

    @inject IOrderStatusesRepository repository
    

    @if (statuses != null && statuses.Count > 0)
    {
    <div class="form-floating mb-3">
    <select @bind="@SelectedId" class="form-select">
    <option value="" selected>-- Не выбран статус --</option>
    @foreach (var item in statuses)
    {
    <option value="@item.Id">@item.Name</option>
    }
    </select>
    <label class="form-label">Статус заказа</label>
    </div>
    }
    else if (statuses != null && statuses.Count == 0)
    {
    <div class="alert alert-danger">Нет статусов для заказов</div>
    }

    @code {
    List<MAOrderStatus>? statuses;

    public int? SelectedId { get; set; }
    
    protected override async Task OnInitializedAsync()
    {
        statuses = await repository.GetAllAsync();
    }
    

    }

    The question is, how is it right and better to make this big object? Is there any way to phase out the order? To open a page with the choice of status, then with the choice of category and so on, at the end of the position?
    PS: .NET 6



  • You have two options: a large facility or a phased facility. In the Habre there were articles about UI and about your example(s) it was also specifically recommended that it be divided into stages. Not as you propose by status, category and e.g., but split it into 2-3 sense parts. On the front page, first download all the data you need, and then send them to your components, for example, through the parameters [Parameter] and OnParametersSet/OnParametersSetAsync. I'll try to find the article myself.

    The material is such a component https://material.io/archive/guidelines/components/steppers.html# ♪ For wpf library materialdesign is expanding https://github.com/spiegelp/MaterialDesignExtensions and has implemented this component. Try it, test it, and you can do something similar and user-friendly.

    It's not a big deal.

    1. Why is MAOrder, MAOrderPosition next to each thing having her id? Why do you need id if you can get it from Worker.Id when Right. Is there a connection between the creatures? For example:
      public ApplicationUser? Worker { get; set; }
      public string? WorkerId { get; set; }
    
    1. You don't like the free side library of the components? Their https://medium.com/@alexandre.malavasi/top-10-nice-free-blazor-components-b42875e56b28 ♪ I'll use it personally. https://github.com/MudBlazor/MudBlazor/ ♪


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2