In C# I can easily create an anonymous object like this at the compile time:
var items = new {
Price = 2000,
Description = "",
Locations = new List<string> { "", "" }
};
My question is, it's possible to create this object at the runtime ? I've heard of emit/meta programming, but I don't know if it helps here.
Noting that these objects will be created inside a for loop (100 items or more), so I recommend techniques that allow type caching.
Thanks.
Update - Why I need this
- One example could be implementing the
Include
functionality like indb.Users.Include("Users")
, so I need to add theUsers
property at runtime on demand.
for
loop just to see what you are trying – Herpetology