Creating Index Action

First, we want to display all of the items in table to the page. The key idea is querying the SQL table and store the result in collection, i.e. List, then throw the collection to View using model.

Remember about LINQ?

// create the genreList variable
List<GenreModel> genreList = new List<GenreModel>();

// perform linq operation
var query = from genre in context.Genres select genre;

// store the query to list
var genres = query.ToList();

results matching ""

    No results matching ""