c# - How to return linq query into single object -


itemprop = "text">

I have this code in my controller:

  public ActionResult description (integer ID) {< Using (dB = new MatchGamingEntities) (db = new MatchGamingEntities ()) {db.Matches is included in db.MatchTypeId on m mtTypeId equals to M.M. MyMatches = n.MatchTypeId where m.MatchId == ID is selected New MatchesViewModel {matchtype = n.MatchTypeName, MatchId = M. Match ID, Machanam = M. Mattitle, Matilda = M. Match description, wizzy = m. Wagon}; See bagmaymats = mimates Toolist (); See Return (MyMatches.ToList ()); }}   

I can return only one query to this query and I can use MyMatches as a MatchesViewModel object so I do not need to use the ToList Want to be able to create () feature to get rid of IEnumberable on the watch page thus @model IEnumerable & LT; MatchGaming.Models.MatchesViewModel & gt; So I can change it in: @model MatchGaming.Models.MatchesViewModel

You can call the proper name extension method.

Here are some other related methods and the differences between them depends on how many elemental collections you want to know:

 An element throws an element more than the first exception returned the first element FirstOrDefault Default (T) first throws an unmaxed exception Exception returns thrown exceptions Default default (T) throws exceptions   

Comments