AssocOneToMany.Controllers.Manager.TeamGetByIdWithPlayers C# (CSharp) Method

TeamGetByIdWithPlayers() public method

public TeamGetByIdWithPlayers ( int id ) : TeamWithPlayers
id int
return TeamWithPlayers
        public TeamWithPlayers TeamGetByIdWithPlayers(int id)
        {
            // Attempt to fetch the object
            var o = ds.Teams.Include("Players").SingleOrDefault(t => t.Id == id);

            // Return the result, or null if not found
            return (o == null) ? null : Mapper.Map<TeamWithPlayers>(o);
        }

Usage Example

コード例 #1
0
        public ActionResult DetailsWithPlayers(int?id)
        {
            // Attempt to get the matching object
            var o = m.TeamGetByIdWithPlayers(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Pass the object to the view
                return(View(o));
            }
        }