Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3596582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:00:25+00:00 2026-05-18T20:00:25+00:00

I am working through the Mvc Music Store tutorial and am stuck on this

  • 0

I am working through the Mvc Music Store tutorial and am stuck on this LINQ query as it keeps telling me that the sequence has no elements. My model matches the model in the tutorial and I have inserted data into it. I have modified it so instead of albums it is designs.

var genreModel = storeDB.DesignTypes.Include("Designs")
            .Single(g => g.Name == designType); -> no elements in sequence

var viewModel = new StoreBrowseViewModel() {
    Genre = genreModel,
    Albums = genreModel.Designs.ToList()
};

return View(viewModel);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:00:25+00:00Added an answer on May 18, 2026 at 8:00 pm

    use FirstOrDefault instead of Single:

    var genreModel = storeDB.DesignTypes.Include("Designs")
                .FirstOrDefault(g => g.Name == designType);
    

    From msdn:

    Enumerable.Single Method
    Returns the only element of a
    sequence, and throws an exception if
    there is not exactly one element in
    the sequence.

    You have more than one match item or no item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just working through a tutorial on asp.net/mvc for the music store application. Ref: http://www.asp.net/mvc/tutorials/mvc-music-store-part-3
I'm working through the MVC Music Store in Visual Basic (mvcmusicstore.codeplex.com), trying to convert
I'm working through the NerdDinner MVC tutorial and came across this and was wondering
Working through a tutorial (Professional ASP.NET MVC - Nerd Dinner), I came across this
This is probably a very simple question that I am working through in an
Working through Pro ASP.NET MVC book and I got the following code snippet that
I have been working through Microsoft's ASP.NET MVC tutorials, ending up at this page
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I'm currently working through an assignment that deals with Big-O and running times. I
I am working through my new MVC book and of course, the samples are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.