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
1
vote
0 answers

How to simulate GetType().GetProperties() and PropertyInfo.GetValue() for ExpandoObject in C#

I need to attach dynamic properties (number of properties and their names are all unknown at design and compile time, they are only known at runtime through an web service call) to an c# object. In this case, I am trying to use ExpandoObject and…
kzfid
  • 688
  • 3
  • 10
  • 17
1
vote
1 answer

Dynamic(ExpandoObject) vs static type(Model) in asp.net mvc

Dynamic vs static type in asp.net mvc Is car better than motorcycle? It all depends on the scenario you are using it. Without knowing the scenario it is not possible to make that determination! Is Dynamic typing better than static typing for…
Mangesh
  • 3,987
  • 2
  • 31
  • 52
1
vote
1 answer

Jint (.NET javascript parser) always returns ExpandoObject

I try to write a mod for a game. This is totally new territory for me, so I might be on the wrong track here. The game is written in Unity and you are able to add a .script file to your mod. The .script file can contain javascript that is parsed by…
Vencarii
  • 45
  • 6
1
vote
2 answers

C# Key Value Default as Key

:) I'm looking for something that I saw in a project few month ago. I don't know what they use and I'm very interrested to know how it work but i don't know how to search for it... and I'm looking for it during 6 hours now.. can you help me to…
1
vote
1 answer

How to convert an entire object graph to ExpandoObject?

I have this object hierarchy/graph: Person: (Name,string) (Age,int?) (Guid,Guid?) (Interests,List) Interest: (Name,string) (IsProfession,bool?) (RequiredSkills,List) Skill: (Title,string) (HoursToAccomplish,int?) So,…
1
vote
1 answer

Iterating through ExpandoObject throws StackOverflowException

I have an expando, like dynamic x = new ExpandoObject (); AddProperty (x, "Name", "Nick"); AddProperty (x, "Seat", "8H"); AddProperty (x, "Code", "11"); Console.WriteLine(x.Name); Console.WriteLine (x.Seat); Console.WriteLine (x.Code); and I use…
Nick
  • 483
  • 1
  • 6
  • 15
1
vote
0 answers

C# expando creating from JSON with validity check against Linked Classes model

I have the below rather simple build of classes, they represent a model, kindly note the linked classes (initialization included in appropriate instance constructors of each one): public class DataClass { public int num { get; set; } …
Nick
  • 483
  • 1
  • 6
  • 15
1
vote
1 answer

ExpandoObject in ViewState

Interestingly enough while developing a module on an ASP.NET web app, I've been storing some cached object data in the ViewState, some well defined and some not (ie: declaring them as dynamic and initializing them as ExpandoObject). This works fine…
Roberto Andrade
  • 1,793
  • 1
  • 21
  • 27
1
vote
0 answers

Dynamic type fields and allocations in C# (.NET Core 2.0)

I'm trying to understand why declaring a private field as dynamic and then using it as a parameter for a function would cause several memory allocations when calling that function later; while if I declare the field as an object it seems to cause no…
Hans
  • 545
  • 2
  • 10
  • 20
1
vote
1 answer

Using an ExpandoObject instead of the original entity in an expression

I have an expression like: Expression> exp = x => x.FirstName == "Jonas"; The expression is transferred to another application which do not have the type MyEntity. To able to execute the expression I'm trying to replace the…
jgauffin
  • 99,844
  • 45
  • 235
  • 372
1
vote
0 answers

Automapper convert to Expandoobject - A lambda Expression with a statement body cannot be converted to an expression tree

I am looking to convert the following dictionary to an expandoobject: var dicToConvert = new dictionary() My CustomAttribute class has the following properties: int AttributeId string AttributeValue int tId I'd like the…
chrisSpaceman
  • 249
  • 3
  • 14
1
vote
2 answers

Is ExpandoObject thread-safe?

Simple question, but docs are silent. In sources there are some locks, so probably it is, but I want to know for sure. Maybe there is an existing answer before I attempted to write a test? If none, how would such test looks like (I am not sure what…
Sinatr
  • 20,892
  • 15
  • 90
  • 319
1
vote
1 answer

Is there a possibility to control the Expando class to not allow adding properties/members under certain conditions?

As far as I can tell, the Expando class in Kephas allows adding new members on the fly. Unlike the ExpandoObject in .NET, I noticed it is not sealed, so I could change its behavior, but I don't really know how. [EDITED] My scenario is to make the…
Auguste Leroi
  • 215
  • 1
  • 7
1
vote
2 answers

How is a method with out parameters assigned to an ExpandoObject?

I'm trying to assign a method (function) to an ExpandoObject with this signature: public List CreateList(string input1, out bool processingStatus) { //method code... } I've tried to do something like this code below which doesn't…
Sixto Saez
  • 12,610
  • 5
  • 43
  • 51
1
vote
1 answer

Remove Escape Character '\' from dynamic JSON using ExpandoObject and IDictionary

I am creating a Dynamic JSON using ExpandoObject and IDictionary. My Sample Code is as below : DataTable dt_MappedColumns = new DataTable(); dt_MappedColumns.Columns.Add("Sr.No"); dt_MappedColumns.Columns.Add("TColumnName"); …
Mufaddal
  • 558
  • 5
  • 24