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
7
votes
3 answers

Passing dynamic parameters with ExpandoObject

I have some function whose prototype looks kind of like this: public void doThings(string sql, dynamic dParams); It does some kind of SQL querying with those parameters. I didn't write it but I have to use it. It works fine when I do something like…
idlackage
  • 2,715
  • 8
  • 31
  • 52
7
votes
2 answers

Exposing properties of an ExpandoObject

I've got an ExpandoObject that I'm sending to an external library method which takes an object. From what I've seen this external lib uses TypeDescriptor.GetProperties internally and that seems to cause some problems with my ExpandoObject. I could…
Johan Leino
  • 3,473
  • 1
  • 26
  • 27
7
votes
1 answer

Define a calculated property on an expando object

I am working with expando object and I am trying to define a calculated property. I know that I can define a simple property by doing something like the following: dynamic myExpando = new…
SPArcheon
  • 1,273
  • 1
  • 19
  • 36
6
votes
2 answers

How to sort a List containing ExpandoObjects

I have a list which contains a dictionary of ExpandoObjects. Im binding this to a grid but now I want to sort the list. var rows = new List(); for (int i = 0; i < 1000; i++) { dynamic expandy = new…
WooHoo
  • 1,912
  • 17
  • 22
6
votes
1 answer

How to serialize ExpandoObject using ServiceStack JsonSerializer?

Is it possible to get the ServiceStack JsonSerializer to serialize an ExpandoObject as a flat object rather than a dictionary? Something roughly approximate to this: {"x":"xvalue","y":"\/Date(1313966045485)\/"} I am trying to compare JSON…
patridge
  • 26,385
  • 18
  • 89
  • 135
6
votes
2 answers

Is it possible to create a Dynamic tree structure using the ExpandoObject?

at the moment I am using the ExpandoObject to dynamically store firstname and surname. e.g. // Create Expando object for testing dynamic employee = new ExpandoObject(); // Dynamically add the fields to the expando …
kevchadders
  • 8,335
  • 4
  • 42
  • 61
6
votes
2 answers

.net expando object and LINQ. Possible or not?

I have a simple list of expando objects called products. i add various fields to these objects at runtime ( for example color or size) How can i write a LINQ query on this list based on dynamic fields ? With a classic list of objects i could write…
alainb
  • 185
  • 1
  • 6
6
votes
1 answer

Is it possible to use ExpandoObject to create run-time properties?

Normally, we can create properties like this, dynamic expando = new ExpandoObject(); expando.Price = 45k; expando.Value = "Good"; In my case, I won't know the properties such as "Price" or "Value" until runtime. How, can I create such dynamic…
Prince Ashitaka
  • 8,623
  • 12
  • 48
  • 71
6
votes
1 answer

A substitute for ExpandoObject in .NET 3.5 with least overhead

How can I imitate the functionality of the ExpandoObject in a .NET 3.5 application with the least overhead? My best lead so far is to use the Lin Fu framework ( http://www.codeproject.com/KB/cs/LinFuPart2.aspx ), but I'm thinking there may be…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
6
votes
2 answers

Adding methods to ExpandoObjects

UPDATE The problem is not the code, the problem is that you apparently can't evaluate dynamic objects from the immediate window. I'm trying to tack on methods to an ExpandoObject but not sure how to get it to work. Here's my code: dynamic myObj =…
Micah
  • 111,873
  • 86
  • 233
  • 325
6
votes
1 answer

Is it possible to query list of ExpandoObject?

I wonder if it is possible to query ExpandoObject with regular LINQ? Reason is that I have dynamic ExpandoObject but I need to do some querying before I can pass further. It has some properties that always stay e.g. Id, Notes but also some dynamic…
Stan
  • 25,744
  • 53
  • 164
  • 242
6
votes
3 answers

convert from dynamic xml to c# object

I need inputs in converting an dynamic xml to defined c# object model My sample xml is as below : 10 Dino Esposito…
KRP
  • 131
  • 1
  • 3
  • 15
6
votes
4 answers

Dynamically add nested property to ExpandoObject

I'm getting a JSON object (may contain multiple levels of JSON arrays and such) which I want to translate into an ExpandoObject. I figured out how to add simple properties to an ExpandoObject at runtime as it implements IDictionary, but how do I add…
Alex
  • 75,813
  • 86
  • 255
  • 348
5
votes
1 answer

Dynamic View of ExpandoObjects "hides" Properties with null Values

I have some code that works with ExpandoObjects populated by database calls. Invariably some of the values are nulls. When I look at the objects as an ExpandoObject, I see all the keys and values (nulls included) in the underlying dictionary. But…
Tim Trout
  • 1,062
  • 12
  • 20
5
votes
1 answer

DynamicObject and TrySetMember performance vs ExpandoObject performance

I'm using a custom implementation of a DynamicObject which works perfectly for my application, other than the fact that I'm running into some performance issues. Some performance overhead is to be expected with dynamics, but I'm seeing significant…
bjquinn
  • 53
  • 1
  • 4