Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ to Entities does not recognize the method 'System.String ToString(Int32)' method, and this method cannot be translated into a store expression
    primarykey
    data
    text
    <p>Using MVC3 VS2010 and SQL Server 2008 Express I am trying to filter based on two SQL Server tables and display the result. One table is clients table and the other is agent. They have in common ClientAgentID in the clients table and ID in the Agents table. An agent logs and should be able to see the clients assigned to the agent. If you have any ideas on the best way to do this please help me. So far I am trying to filter in the clients controller and here is what I have but the message is I am getting is in the title.</p> <pre><code> public ActionResult Index() { //This displays all the clients not filtered by the Agent ID number //var clientItems = db.MVCInternetApplicationPkg; //return View(clientItems.ToList()); //Trying to filter by the agent name given in the login page then finding //the agent ID var getAgentID = from a in db.AgentsPkg where a.AgentLogin == User.Identity.Name select a.ID; var clientItems = from r in db.MVCInternetApplicationPkg where Convert.ToString(r.ClientAgentID) == Convert.ToString(getAgentID) select r; //THIS IS THE LINE OF CODE THAT SHOWS THE ERROR MESSAGE return View(clientItems.ToList()); } </code></pre> <p>This is my first MVC project after the Music Store so am willing to learn and accept any help or advice. Cheers</p> <p>Here is the solution that I used in the end. Any feed back on if this is a good approach would be appreciated</p> <pre><code> public ActionResult Index() { var innerJoint = from agents in db.AgentsPkg where agents.AgentLogin == User.Identity.Name join clients in db.MVCInternetApplicationPkg on agents.ID equals clients.ClientAgentID select clients; return View(innerJoint.ToList()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload