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
1 answer

How to find types in IEnumerable returned by PetaPoco.Database.Query?

I'd like to find out at runtime all the types in an ExpandoObject. Here's some exploratory code: using PetaPoco; ... var data = _d.Query(_script); IDictionary hood = (IDictionary)data.First(); var wow =…
Guy--L
  • 170
  • 2
  • 13
1
vote
2 answers

How to bind a collection of ExpandoObjects to a Data Grid?

I'm trying to read a table from an Excel file (.xls) and display it in a DataGrid. The table has unknown dimensions and each column has values of one unknown type (string, double or int). I access the file via COM and put the table in a List<> of…
himmelsfisch
  • 35
  • 1
  • 6
1
vote
1 answer

Getting values of ExpandoObject from Keys that are known at runtime

I am using CsvHelper to read a CSV file so I can write "some" of its columns to somewhere else. I don't have the name of headers beforehand so I couldn't use ClassMapper . However I can get a List of the names of columns at runtime because they are…
UnskilledCoder
  • 192
  • 1
  • 11
1
vote
2 answers

C# Replace an array in a JSON file

I'm trying to replace an array in a JSON file using C# .net 6.0 There is such a JSON file: { ... "exchange":{ ... "pair_whitelist": [ "EOS3S/USDT", "ACH/USDT", "SOC/USDT"] ... } ... } I want to replace this "pair_whitelist" array…
Oleksandr Myronchuk
  • 155
  • 1
  • 2
  • 10
1
vote
0 answers

ElasticSearch Nest Mapping for Nested ExpandoObject for RabbitMQ Bus Messages

I'm running into a problem logging messages from a RabbitMQ Bus (yes, i know that's against recommendation) into ElasticSearch via Nest (v7.17.5). 100+ different messages get consumed that all have differing JSON objects that get expanded into…
Luke J
  • 11
  • 1
1
vote
0 answers

Walk Object Tree to extract value types

Given an infinitely nested object with unknown properties. What is the best approach to extract all the leaf value types (strings, ints, doubles and decimals). Duplicate property names need to be retained. Is there a good way to do this in C#. Have…
Andrew Gray
  • 3,593
  • 3
  • 35
  • 62
1
vote
1 answer

How can I add a ExpandoObject to an already existing ExpandoObject?

Here is my code: dynamic App = new ExpandoObject(); //App names are SAP, CRM and ERP //App names - adding static //App.SAP = new ExpandoObject(); //App.CRM = new ExpandoObject(); //App.ERP = new ExpandoObject(); In the last 4 lines, I am adding…
misterraj
  • 47
  • 1
  • 5
1
vote
1 answer

Bind ExpandoObject to MudBlazor Form Controls

I am trying to accomplish Functionality similar to Angular FormBuilder, where we dynamically add Controls and Validations. In MudBlazor or Blazor in general, we have to use C# Model to bind with Controls. So I decided to use ExpandoObject with…
Mohiyo Deen
  • 137
  • 3
  • 17
1
vote
0 answers

Casting ExpandoObject to dictionary creates nullable reference warning

I have nullable reference types turned on and I have the following block of code: ExpandoObject? e1 = null; ExpandoObject e2 = null; ExpandoObject e3 = new(); var d1 = (IDictionary)e1; var d2 =…
Sun
  • 4,458
  • 14
  • 66
  • 108
1
vote
1 answer

Add new [] values to ExpandoObject

I want to add all values from myArr to myObj. int[,] myArr = { {1, 2}, {3, 4} }; dynamic myObj = new ExpandoObject(); foreach(var myInt in myArr) { myObj.Ints = new[] { new { value = myInt, …
MTS
  • 104
  • 7
1
vote
1 answer

Can an ExpandoObject have a strongly typed parent?

Using ExpandoObject, is it possible to subclass a class with typed properties and only add dynamically the properties that come up during runtime? class TypedProperties { public int KnownIntProperty { get; set; } public string…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
1
vote
1 answer

Can YamlDotNet Deserialize to an dynamic object graph?

I have a large YAML document that I want to deserialize to a dynamic object (ExpandoObject). Can YamlDotNet deserialize directly to a dynamic object tree? I can get there by going to Json first and then using NewtonSoft to deserialize to an…
dkackman
  • 15,179
  • 13
  • 69
  • 123
1
vote
2 answers

How to search in generic list of ExpandoObject

Following up on my previous question. I am now trying to find a specific occurrence of an XML-part. For instance in the following XML (part)
John
  • 87
  • 11
1
vote
1 answer

How to traverse an ExpandoObject and get specific values

I have the following XML (part)
John
  • 87
  • 11
1
vote
1 answer

Removing a property in ExpandoObject

I am using an API to get a collection of JSON responses and I am putting them in an ExpandoObject result. The property I want to delete is in result.data.attributes.image_url for example. I don't need it and wish to remove it from the entire…
Cristian
  • 111
  • 1
  • 7