The challenge is that Html.Lazy uses referential equality and hence fails entirely if you construct any of its parameters during the view call because those constructed parameters will not be referentially equal to parameters you constructed the last time.
We’ve got native code that does referentially transparent and functionally pure deduping which helps, but it’s native code and sharing that is discouraged here. It also comes with the tricky part that you need to have a separate deduper for each path you care about for it to be effective. I generally stick it in the model.
Without resorting to native code, what you can do if some of your parameters come from a small space of values —e.g., you need a Boolean parameter — is build module-level functions that prebind those values and then choose amongst those functions in the render. This way, you get the number of arguments that you need to pass to Html.Lazy down.
Mark