csv - CSVHelper: No properties are mapped for type 'class name' -


i getting exception while run time mapping. see code below:

    namespace csvtest { class program { static void main(string[] args) { streamreader textreader = new streamreader("book1.csv"); var csv = new csvreader(textreader, new csvhelper.configuration.csvconfiguration() { willthrowonmissingfield = false });          string[] csvfieldnames = { "name" };         string[] modelproperties = { "name" };          var manufacturermap = new defaultcsvclassmap<manufacturer>();         (int = 0; < csvfieldnames.length; i++)         {             var propertyinfo = typeof(manufacturer).gettype().getproperty(modelproperties[i]);             var newmap = new csvpropertymap(propertyinfo);             newmap.name(csvfieldnames[i]);             manufacturermap.propertymaps.add(newmap);         }          csv.configuration.registerclassmap(manufacturermap);          var test = csv.getrecords<manufacturer>().tolist();     } }  public class manufacturer {     public int id { get; set; }     public string name { get; set; } } } 

here csv file content

sku,name,purchaseprice,test 1,aa,10,2 2,bb,20,2 3,cc,30,3 4,dd,40,4 5,ww,50,5 

which give exception : no properties mapped type 'csvtest.manufacturer'. [note : can see mapping entry while debugging still throws exception]

any solution?

thanks!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -