A
A
Alyosha2018-02-23 10:33:48
ASP.NET
Alyosha, 2018-02-23 10:33:48

How to output a certain number of records from a table in asp.net core?

I output data to the MVC page with the following code

@foreach (var item in Model)
        {
@Html.Raw(item.Content.Substring(0,500))
}

How can I limit the number of output lines? For example, I want to display only the last 2 entries added. Now all the rows that are in the database are displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alyosha, 2018-02-23
@digna

If anyone is interested, then I found a solution, this is the use of LINQ in the controller.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question