M
M
Muxailo2017-04-29 20:15:14
ASP.NET
Muxailo, 2017-04-29 20:15:14

How to make a selection in Entity Framework without @foreach?

Hello. There is such a small database.
db.Books.Add(new Book { Name = "book1", Author = "author1", Price = 220 });
db.Books.Add(new Book { Name = "book2", Author = "author2", Price = 180 });
db.Books.Add(new Book { Name = "book3", Author = "author3", Price = 150 });
the question is how to make a selection for output in the view file. (Selecting each element), and not through foreach (var b in ViewBag.Books)
{
@b.Name
@b.Author
@b.Price
}
You just need to select, for example, author1, and output it to an HTML file.
ps project in mvc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gavrilenko, 2017-04-29
@Maddox

Selecting each element, not through foreach

Chet is not very clear here. Then it says select author1 and output.
Initially, it is necessary to display a list for any possible in , and then send the data to another Action controller, which will determine which author was selected and display information in the view of only this author. <select>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question