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

  • SEARCH
  • Home
  • 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 616305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:18:46+00:00 2026-05-13T18:18:46+00:00

Working through the WROX Beginning ASP.NET MVC 1.0 book I’ve hit a strange ‘error’.

  • 0

Working through the WROX “Beginning ASP.NET MVC 1.0” book I’ve hit a strange ‘error’.

“Operator ‘==’ cannot be applied to operands of type ‘System.Guid’ or ‘int'”. The line in questions is:

(p => p.ID_Officers == id).Single();

The full code is below, and Officers is my table, ID_Officers is my ID field. (I imagine that I could of used ‘o’ instead of ‘p’)

public ActionResult IndividualOfficer(int id)
    {
        OfficersDataContext dataContext = new OfficersDataContext();
        Officer officer = dataContext.Officers.Where
            (p => p.ID_Officers == id).Single();
        ViewData["OfficerName"] = officer.OfficerName;
        ViewData["Officer"] = officer;

        return View();
    }

Any words of wisdom for this beginner would be appreciated.

I might add, that although this book was recommended for beginners – boy it’s dry. It’s clearly laid out, obvious to see what needs to be added/typed in during the exercises, but I feel it’s written for an experienced programmer coming over to MVC. Rather than a beginner programmer.

So, does anyone know of a more beginner friendly book (I like books and reading) that I could more easily sink my time and teeth into?

Thanks for your help and guidance.

Mike

  • 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-13T18:18:47+00:00Added an answer on May 13, 2026 at 6:18 pm

    Its very simple.

    id is an int. p.ID_Officers is, as the error message states, a Guid, which is not an int and cannot be checked against an int for equality. Two different types, you know.

    I’m not sure where the id of the controller method comes from. At some time you must present to the user a list of officers, and construct links that point to each individual officer which includes the p.ID_Officers in the definition of the link, but your route is expecting an int. Without seeing how your routes are configured or your officer links are constructed, I can’t give you much more of a hint than that.

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

Sidebar

Related Questions

Working through Pro ASP.NET MVC book and I got the following code snippet that
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
Working through a tutorial (Professional ASP.NET MVC - Nerd Dinner), I came across this
I'm working through the 4th ed. of the Hillegass/Preble Cocoa book and have hit
So I'm working through the new scottgu wrox book, and I create a couple
I'm working through Practical Web 2.0 Appications currently and have hit a bit of
Just working through the Agile Web Development with Rails book and near the closing
I am working through a Zend framework book and is stuck for days on
I'm working through the book Real-World Functional Programming , and I tried to come
I am working through a REST services book dealing with WCF. I have been

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.