Questions tagged [expandoobject]

ExpandoObject is a .NET type whose members can be added and removed at runtime.

From msdn: Represents an object whose members can be dynamically added and removed at run time.

Instances are typically declared with the dynamic keyword:

dynamic sampleObject = new ExpandoObject();

This type is part of System.Dynamic and was introduced with .NET 4.

356 questions
2
votes
1 answer

Two-Way databinding dynamic object on winform controls

I want to databind a Dynamic object to a control in a winform app. So far I got it somewhat working, it does seems to databind "the first time", but then when I change the property value it does not take effect on the binded control, and that's the…
2
votes
1 answer

Dynamic property assigned to object

Is it possible to attach dynamic property to an object of user-defined class? public class Room { public int NumberOfDoors { get; set; } public int NumberOfWindows { get; set; } } then from other context: Room room = new Room(); dynamic…
Annie
  • 3,090
  • 9
  • 36
  • 74
2
votes
1 answer

Servicestack ORMLite/Massive managing multiple DataTables with Expandos / Dynamic?

i have a Stored Procedure that returns multiple datatables with dynamic types according to the input and I cannot modify or split it. I actually retrieve the data in this way: var massiveModel = new DynamicModel(dbConn.ConnectionString); …
2
votes
1 answer

Converting ExpandoObject to a Type, What is more efficient and less time consuming, doing that client side or server side?

Problem Definition: I got an ExpandoObject that i need to convert to a Type like "Customer" Type, the problem is not achieving that, am wondering should i approach that server side or client side using javascript, i can achieve what i want both ways…
2
votes
0 answers

What is the proper way of referencing an ExpandoObject inside a StringTemplate?

I have a ViewData value taken from an ExpandoObject like this in a Controller: public ActionResult CountryData() { string json = "{\"Countries\":[{\"CountryId\":1,\"Country\":\"USA\",\"Description\":\"North…
Noble_Bright_Life
  • 569
  • 3
  • 9
  • 16
2
votes
1 answer

ExpandoObject in Nemerle

AFAIK Nemerle doesn't have dynamic keyword, late binding doesn't work as well: late{ mutable obj=ExpandoObject(); obj.test="test"; //MissingMethodException } So, is there a way to use ExpandoObject in Nemerle?
2
votes
3 answers

Why can't I return an Interface on implicit casting, but ExpandoObject can?

I have a DynamicObjectand I want it to be castable to IDictionary, exactly the same way as ExpandoObject. For example, casting an ExpandoObject to IDictionary is perfectly valid: dynamic ex = new ExpandoObject (); ex.Field =…
Dynalon
  • 6,577
  • 10
  • 54
  • 84
2
votes
3 answers

Merging two similar dynamic objects in C# creating collections on the way

I have multiple dynamic objects that (most of the time) differ in only a few values. I want to be able to merge these objects into one single object and in case of a conflict (two values aren't the same) then I want these to be stored in a…
Joey Dewd
  • 1,804
  • 3
  • 20
  • 43
2
votes
3 answers

How to add object property on expando at runtime?

I read some article regarding expando object here but I want to achieve different thing. I want to add property object with dynamic property at runtime, put value on it and then retrieve later: private static readonly…
fiberOptics
  • 6,955
  • 25
  • 70
  • 105
2
votes
1 answer

Passing Dictionary to ObjectForScripting with WPF WebBrowser

I am using a WebBrowser component in WPF to host some JavaScript + HTML and I want to be able to pass a customisable object in as the ObjectForScripting property. My end goal is that the javascript running in the WebBrowser can call something…
Steve Greatrex
  • 15,789
  • 5
  • 59
  • 73
2
votes
1 answer

ExpandoObject with Spring expression

I made object using ExpandoObject class and I want to perform spring.net expression on that object, but then I got following error: 'Name' node cannot be resolved for the specified context [System.Dynamic.ExpandoObject]. Code looks like: …
Adam Łepkowski
  • 2,048
  • 1
  • 24
  • 41
2
votes
1 answer

Determine Object Type in ExpandoObject

I have derived a class which will take an XML file and generate ExpandoObject dynamically for the XML being passed in utilizing Lists of ExpandoObjects and recursion. Passing this back to be processed to retrieve data works, but the XML that I am…
RobW
  • 25
  • 5
2
votes
2 answers

Periods in the name of c# dynamic ExpandoObjects?

Maybe this is a silly question, but I'm working on a project that wants me to generate some JSON that looks like this: {'action.type':'post', 'application':APP_ID} In C#, I'm trying to create this "action.type" attribute, with the value of "post".…
kevin
  • 417
  • 4
  • 20
1
vote
2 answers

Assign the literal string as a property of a dynamic object during runtime and access it

How can I assign the fieldname of a sqldatareader during runtime dynamically to a dynamic object? Lets assume I have read the fieldname of a SqlDataReader into a variable: string sqlDataReaderFieldNameStringVariable = reader.GetName(index); I can…
Pascal
  • 12,265
  • 25
  • 103
  • 195
1
vote
2 answers

Expando dynamic object passing to other class requires Microsoft.CSharp.dll?

I have build a function: string removeFile(HttpContext context,HttpRequest r) { dynamic d = new ExpandoObject() ; d.ItemCommand = r["itemId"].ToString(); ... ... int res = new…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792