Answer the question
In order to leave comments, you need to log in
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
Selecting each element, not through foreach
<select>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question