Как загрузить большие данные в наборах данных в c# - PullRequest
0 голосов
/ 13 февраля 2020

Я работаю над. NET Базовая структура (C#) и использую DataTable для отображения моих данных на стороне клиента. Но загрузка веб-страницы занимает слишком много времени. Есть ли способ загрузить данные в наборах? (Я уже искал то же самое, но ничего не получил.

Мой метод действия на контроллере, где я храню данные в представлении Свойство модели (IEnumerable)

public IActionResult Index()
{
     _flatInvoiceViewModel.FlatInvoiceModels = _flatInvoiceLogic.GetLatestInvoice(GetRequestDto(string.Empty));
      return View(_flatInvoiceViewModel);
}


this is my view:

``
<table class="table table-bordered mydatatable table-hover nowrap table-sm">


    <thead class="thead-light">
        <tr>
            <th class="mobile tablet desktop">Flat Number</th>
            <th class="mobile tablet desktop">Owner</th>
            <th>Invoice Number</th>
            <th class="mobile tablet desktop">Invoice Date</th>
            <th class="not-mobile">Due Date</th>
            <th>Amount</th>
            <th class="mobile tablet desktop"> View</th>
        </tr>
    </thead>

    <tbody class="bg-white">
        @foreach (var item in Model.FlatInvoiceModels)
        {
            <tr>
                <td>@item.FlatNumber</td>
                <td>@item.AccountName </td>
                <td>@item.DisplayInvoiceNumber</td>
                <td>@item.InvoiceDate.ToString("dd-MM-yyyy")</td>
                <td>@item.DueDate.ToString("dd-MM-yyyy")</td>
                <td>@item.GrandTotalAmount.ToString("0")</td>
                <td>
                    <a target="_blank" asp-controller="FlatInvoice" asp-action="ShowDetails" asp-route-FlatInvoiceRid="@item.FlatInvoiceRid" class="btn btn-sm btn-outline-primary p-1 mr-0">View</a>
                </td>
            </tr>
        }
    </tbody>

    <tfoot>
        <tr>
            <th class="mobile tablet desktop">Flat Number</th>
            <th class="mobile tablet desktop">Owner</th>
            <th>Invoice Number</th>
            <th class="mobile tablet desktop">Invoice Date</th>
            <th class="not-mobile">Due Date</th>
            <th>Amount</th>
            <th class="mobile tablet desktop"> View</th>
        </tr>
    </tfoot>
</table>

<link rel="stylesheet" href="~/DataTables/datatables.min.css" />
<script type="text/javascript" src="~/DataTables/datatables.min.js"></script>

...