RickStrahl / Expando

Extensible dynamic types for .NET
108 stars 30 forks source link

remove property from Westwind.Utilities.Dynamic.Expando #15

Closed minaairsupport closed 5 years ago

minaairsupport commented 5 years ago

how to remove property from Westwind.Utilities.Dynamic.Expando

my tries but app crash any way to remove property from object

public class  modelStatic : Westwind.Utilities.Dynamic.Expando
{
public list<string >attachments{get;set;}
....
.. // so other properties 

}
  dynamic dynamicModel = new ExpandoObject();
                dynamicModel = modelStatic;
                ((IDictionary<String, Object>)dynamicModel)?.Remove("attachments");
RickStrahl commented 5 years ago

You can't remove existing static properties. You can only remove dynamic properties you add to the Expando via code. Otherwise they are not in the dictionary...