Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

What does AsNoTracking

$
0
0

please see this code await students.AsNoTracking().ToListAsync() tell me what is AsNoTracking() and what ToListAsync() ?

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/sort-filter-page

public async Task<IActionResult> Index(string sortOrder)
{
    ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
    ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";
    var students = from s in _context.Students
                   select s;
    switch (sortOrder)
    {
        case "name_desc":
            students = students.OrderByDescending(s => s.LastName);
            break;
        case "Date":
            students = students.OrderBy(s => s.EnrollmentDate);
            break;
        case "date_desc":
            students = students.OrderByDescending(s => s.EnrollmentDate);
            break;
        default:
            students = students.OrderBy(s => s.LastName);
            break;
    }
    return View(await students.AsNoTracking().ToListAsync());
}

can i use AsNoTracking() and ToListAsync() in asp.net mvc5 ?

thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>