1

Ok im trying to get a MVC example page working and basically query where a certain id is specified but i'm fairly new to it all and after an hour of trying to figure this out im hoping of you can help me!!

code below is a method from my taskController.cs that is called via /tasks/complete/2

//mark task as complete
    public ActionResult Complete(int id)
    {
        IEnumerable<task> tasks = from t in db.tasks where t.taskID = id select t;


        foreach (task myTask in tasks)
        {
            myTask.isComplete = true;
        }
        db.SubmitChanges();

        return RedirectToAction("Index");
    }
0

2 Answers 2

10

While the terms might sound similar, it's important to remember that LINQ is not SQL. Try using double equals for comparison:

 IEnumerable<task> tasks = from t in db.tasks where t.taskID == id select t;
Sign up to request clarification or add additional context in comments.

2 Comments

thank you, i thought it may be something simple that i'd overlooked - appreciate the help
didn't "=" throw an exception? Does for me.
3

try "==" for "where t.taskID == id"

1 Comment

He probably starting writing at the same time but does it really need commenting on?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.