You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using AsDynamic(...) you can easily make any object dynamic. This is especially useful for anonymous types like this:
var x = AsDynamic(new {
Something = "hello"
});
It's mainly used in these scenarios
Passing back anonymous objects from functions outside of the main razor file
Merging settings from predefined sources with settings from code
Providing properties to sub-templates using Html.Partial("_onether.cshtml", new { Id = 27 }) which are then provided on a dynamic DynamicModel object
The challenge appears when we have sub-objects, like this
var x = AsDynamic(new {
Guid = new Guid(),
Sub = new {
Subproperty = "hello"
},
List = new List<string>(),
Arr = new string[0]
});
In these cases, it's sometimes useful to re-wrap the sub-objects, and sometimes it's a problem. For example, a Guid shouldn't rewrap, because it becomes harder to use, but other anonymous object should be re-wrapped again.
Your environment
2sxc version(s): 12.04
The text was updated successfully, but these errors were encountered:
I'm submitting a ...
[x] change / feature request
...about
[x] Razor templating
[x] internals
Current behavior
Using
AsDynamic(...)
you can easily make any object dynamic. This is especially useful for anonymous types like this:It's mainly used in these scenarios
Html.Partial("_onether.cshtml", new { Id = 27 })
which are then provided on a dynamicDynamicModel
objectThe challenge appears when we have sub-objects, like this
In these cases, it's sometimes useful to re-wrap the sub-objects, and sometimes it's a problem. For example, a Guid shouldn't rewrap, because it becomes harder to use, but other anonymous object should be re-wrapped again.
Your environment
The text was updated successfully, but these errors were encountered: