W
W
WingRS2016-12-18 22:15:16
C++ / C#
WingRS, 2016-12-18 22:15:16

Data output to the appropriate parameters?

There is a class

public class Game
    {
        public int Id { get; set; }
        public DateTime date { get; set; }
        public int? StadiumId { get; set; }
        public Stadium Stadium { get; set; }
        public Team team1 { get; set; }
        public int team1Id { get; set; }
        public Team team2 { get; set; }
        public int team2Id { get; set; }
    }

and class
public class Stadium
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Seats { get; set; }
        public float Price { get; set; }
        public ICollection<Game> Games { get; set; }
        public Stadium()
        {
            Games = new List<Game>();
        }

    }

The question is how in Details (using Code first I created the controllers and the database, however, I created everything) to display the games that are held at the stadium, I tried to display at least the number of games through the collection, it displays 0
<dt>
            @Html.DisplayNameFor(model => model.Games.Count)
        </dt>
        <dd>
            @Html.DisplayFor(model => model.Games.Count)
        </dd>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2016-12-19
@dmitryKovalskiy

In this case, the appearance value of your models and Views is somewhere around zero. Show the code where you retrieve the data and the model generation code. Yes, and so, by the way - using EF in the controller is a very bad idea that smells like bad architecture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question