title: MVC4 : call controller function result in view
body: <p>I want to display an ID find in a datatable in a view. To do that, I do the following :</p>
  
  <ol>
  <li><p>Create the function that will return the ID :</p>
  
  <pre><code>public int getClientID(string login)
  
      {
          var context = new MyEntity(new Uri("host/MyWCF.svc/"));
  
          var userID = from persons in context.PERSON
                       where persons.LOGIN == login
                       select persons.USER_ID;
  
          int uID = userID.First();
          var cli = from client in context.CLIENT
                    where client.USER_ID == uID
                    select client.CLIENT_ID;
          int cliID = cli.First();
          return cliID;
      } 
  </code></pre></li>
  <li><p>And, in my view :</p>
  
  <blockquote>
    <p>Client : @{
    ((HomeController)(this.ViewContext.Controller)).getClientID(User.Identity.Name);
    }</p>
  </blockquote></li>
  </ol>
  
  <p>Where HomeController is the name of my controller where the function is define.
  But doing this, i've got the following error :</p>
  
  <pre><code>Can only specify query options (orderby, where, take, skip) after last navigation
  </code></pre>
  
  <p>At line <code>int uID = userID.First();</code></p>
  
  <p>So, why do I have this error (since I'm using the good namespace in te view) and also, is it a good way to work ?
  Thanks !</p>