problem about expandoobject-Collection of common programming errors


  • xx77aBs
    c#-4.0 asp.net-mvc-4 expandoobject
    Is it possible to convert ExpandoObject to anonymously typed object?Currently I have HtmlHelper extension that can take HTML attributes as a parameter. The problem is that my extension also needs to add some HTML attributes so I’ve use ExpandoObject to merge my attributes and attributes that user passes to the function using htmlAttributes parameter. Now I need to pass merged HTML attributes to original HtmlHelper function, and when I send ExpandoObject, nothing happens. So I guess that I need t

  • smartcaveman
    c# .net-3.5 dynamic runtime expandoobject
    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 something better.To give a better idea of what I am going for here, my objective is to dynamically create the type from the parameters of a MethodInfo. So, basically I want to turn this:public class ServiceObject{public void Execute(string TransformMeInto

  • talles
    c# anonymous-types expandoobject dynamic-typing
    With dynamic we pretty much have a dynamic pointer, but not exactly a dynamic object. The true dynamic object in C# is the ExpandoObject, but that is a really unknown class for most of people. The expando allows creating and removing members at runtime, much like a hash (similar to JavaScript).Why the ExpandoObject goodness was implemented in a separate class rather than just being, let’s say, implemented as a feature of anonymous types?Maybe that wouldn’t be a good move because the lacking of t

  • Newbie

  • aravind srinivas
    c# properties dynamics expandoobject
    I want to create public object Value { get; set; }public Type Type { get; set; }public string Name { get; set; } public string “user has to give propertyname” {get;set;}at run time as per user requirement . Is it possible to do this in Csharp Using Expandos or Dynamics .I am asking that if i want to set property name in runtime linepublic string “user has to give propertyname” {get;set;} .it must be from xml r sql but i want to set property name in runtime.

  • Alex
    c# dynamic 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 nested properties (for example, something like myexpando.somelist.anotherlist.someitem) at runtime that will resolve correctly?Edit: Currently this works for simple (first level) properties well:var exo = new ExpandoObject() as IDictionary<String,

  • idlackage
    c# sql dynamic parameter-passing 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 this:doThings(“select * from SomeTable where myval1=@v1 and myval2=@v2”,new{v1 = new Dapper.DbString(){Value = “yay”,IsAnsi = true,Length = 50},v2 = new Dapper.DbString(){Value = “really”,IsAnsi = true,Length = 32}});But not when I first put the dynami

  • jbtule
    c# dynamic expandoobject
    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 if I try to access them through a dynamic reference, any key that has a corresponding null value does not show up in the dynamic view of the object. I get an ArgumentNullException when I try to access it via property syntax on the dynamic reference.I

  • pratap k
    c# .net dynamic expandoobject
    I have build a function:string removeFile(HttpContext context,HttpRequest r){ dynamic d = new ExpandoObject() ;d.ItemCommand = r[“itemId”].ToString();……int res = new PolicyDal().Admin_Kits_AttachFile(d); //sending here the d.on the other class/file:public int Admin_Kits_AttachFile(dynamic d){DbCommand command = _webERPDB.GetStoredProcCommand(“Admin_Kits_AttachFile”);_webERPDB.AddInParameter(command, “@ItemCommand”, DbType.String, d.ItemCommand);The following error occurs:One or more ty

  • dkackman
    c# c#-4.0 dynamic expandoobject
    I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something likevar x = new ExpandoObject(); x.AddProperty(“NewProp”, System.String);Is this easily possible?

  • Pascal
    c# .net dynamic expandoobject
    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 not say:dynamic dyn = new ExpandoObject(); dyn.sqlDataReaderFieldNameStringVariable = “test”;How can I do that?UPDATE:still time to get a point 😉 I add my dyn object to a List of type ExpandoObject which is the return value of a method. When I access th

  • Ryszard Dzegan
    c# .net reflection aop expandoobject
    Here is the class:class Foo {private void Boo(){// Body…}// Other members… }What I need is:Create a Foo2 class at runtime which has a copy of all Foo class members. In Foo2 class replace Boo method by Boo2 method that has its content alternated to some extent. Create an instance of Foo2 and invoke Boo2.Thank you for help.

  • stakx
    c# .net serialization dynamic expandoobject
    I’m trying to use a System.Dynamic.ExpandoObject so I can dynamically create properties at runtime. Later, I need to pass an instance of this object and the mechanism used requires serialization. Of course, when I attempt to serialize my dynamic object, I get the exception:System.Runtime.Serialization.SerializationException was unhandled.Type ‘System.Dynamic.ExpandoObject’ in Assembly ‘System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ is not marked as serializable.C

  • Beyond Programming
    c# asp.net-mvc-3 knockout.js expandoobject massive
    Problem DescriptionI wanted to ask about how to use a list Exbando Objects in knockout.js,am using Rob Conrey’s Massive and all returned results are dynamic, that’s fine with me it suits my needs but when it comes to sending results to knockout i just don’t know what to do with it.GoalAccess object properties like obj.Name, obj.Brand etc…Sample CodeView:<div data-bind=”foreach: Products”><p>Product name: <strong data-bind=”text: Name”></strong></p> </div>Con

Web site is in building