views:

238

answers:

4

from the free dinner book for asp.net MVC

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection formValues) {
    Dinner dinner = dinnerRepository.GetDinner(id);
    UpdateModel(dinner);
    dinnerRepository.Save();
    return RedirectToAction("Details", new { id = dinner.DinnerID });
}

how to convert this line into vb.net?

return RedirectToAction("Details", new { id = dinner.DinnerID });

more the new { id = dinner.DinnerID } part

thanks

+6  A: 

Try this

Return RedirectToAction("Details", New With { .id = dinner.DinnerID})

In VB the anonymous type declaration syntax, as well as normal object initializers, needs a "." prefix on all of the property names. This is consistent with other VB features such as the With context.

JaredPar
Pedantically edited to captalise the R of "return". :P
Noldorin
thanks !
Fredou
@Norldorin, hah. At least I didn't mispell it!
JaredPar
We are programmers not spelling bee champs... heck even I want to beat up those nerds ;)
Matthew Whited
+1  A: 

That is using an anonymous type, so it will look like this:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })
bdukes
A: 

This should work:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })
Noldorin
A: 
New With {.id = dinner.DinnerID}