title: MVC dynamic routeValues for ActionLinks
body: <p>I have a need to use ActionLink to link to ann edit screen for my ViewModel A.</p>
  
  <p>A has a composite key, so to link to it, the route values will have to have 3 pramaters, like this:</p>
  
  <pre><code>&lt;%: Html.ActionLink("EDIT", "Action", "Controller", 
      new { area = "Admin", Id1= 1, Id2= 2, Id3= 3 })%&gt;
  </code></pre>
  
  <p>As you can see, the route values contain the ids that the controller Action will accept.</p>
  
  <p>I want to be able to generate the route values from a helper function, like this:</p>
  
  <pre><code>public static Object GetRouteValuesForA(A objectA)
      {
          return new
          {
              long Id1= objectA.Id1,
              long Id2= objectA.Id2,
              long Id3= objectA.Id3
          };
      }
  </code></pre>
  
  <p>And then use it in the ActionLink helper, but I don't know how to pass that result to the ActionHelper</p>
  
  <pre><code>objectA = new A(){Id1= objectA.Id1,Id2= objectA.Id2,Id3= objectA.Id3};
  ....
  &lt;%: Html.ActionLink("EDIT", "Action", "Controller", 
      new { area = "Admin", GetRouteValuesForA(objectA) })%&gt;
  </code></pre>
  
  <p>But that would need the controller action to accept that anonymous type instead of a list of 3 properties</p>
  
  <p>I saw the below link that merges anonymous type, but is there any other way to do this?
  <a href="https://stackoverflow.com/questions/6754967/merging-anonymous-types">Merging anonymous types</a></p>