c# - Missing something in this method to get the Entity property -


private string[] getproperties(econtent_econtentfields econtentfield) {     list<string> list = new list<string>();     type fieldtype = econtentfield.gettype();     var properties = fieldtype.getproperties();     foreach (var prop in properties)     {         if (prop.membertype == membertypes.property)         {             if (prop.propertytype.isgenerictype)             {                 dynamic items = prop.getvalue(econtentfield, null);                 foreach (var item in items)                 {                     type typeitem = item.gettype();                     list.add(item);                 }             }         }     }      return list.toarray(); } 

this method retrieve array of strings properties of entity statement:

if (prop.propertytype.isgenerictype) 

it's false. i've copy-pasted code maybe i'm missing something. can't see.

var result = new list<string>(); var type = econtentfield.gettype(); foreach (var prop in type.getproperties()) {      result.add(prop.name);  }   return result.toarray(); } 

this twice faster method, if interested in speed. ps: if change foreach loop, wil bit faster, not lot :)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -