{"action":"created","issue":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/938","repository_url":"https://api.github.com/repos/JoshClose/CsvHelper","labels_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/938/labels{/name}","comments_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/938/comments","events_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/938/events","html_url":"https://github.com/JoshClose/CsvHelper/issues/938","id":302237667,"number":938,"title":"CsvHelper.ValidationException: Header matching ['currentProductId'] names at index 0 was not found","user":{"login":"900v3n","id":35288391,"avatar_url":"https://avatars3.githubusercontent.com/u/35288391?v=4","gravatar_id":"","url":"https://api.github.com/users/900v3n","html_url":"https://github.com/900v3n","followers_url":"https://api.github.com/users/900v3n/followers","following_url":"https://api.github.com/users/900v3n/following{/other_user}","gists_url":"https://api.github.com/users/900v3n/gists{/gist_id}","starred_url":"https://api.github.com/users/900v3n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/900v3n/subscriptions","organizations_url":"https://api.github.com/users/900v3n/orgs","repos_url":"https://api.github.com/users/900v3n/repos","events_url":"https://api.github.com/users/900v3n/events{/privacy}","received_events_url":"https://api.github.com/users/900v3n/received_events","type":"User","site_admin":false},"labels":[{"id":81846939,"url":"https://api.github.com/repos/JoshClose/CsvHelper/labels/question","name":"question","color":"fbca04","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-03-05T10:05:25Z","updated_at":"2018-03-15T05:36:19Z","closed_at":null,"author_association":"NONE","body":"Greetings,\r\n\r\nI'm trying to read a CSV using CsvReader v7.0.1 but keep getting this error:\r\n_'Header matching ['currentProductId'] names at index 0 was not found.'_\r\n\r\n**The CSV file:**\r\n```\r\nProductId\r\nEmail\r\n```\r\n\r\n**The model class:**\r\n```\r\nprivate string currentProductId;\r\nprivate string[] hierarchy;\r\n\r\npublic ProductHierarchy(string currentProductId, params string[] parentProductIds)\r\n{\r\n\tContract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace(currentProductId));\r\n\r\n\tthis.currentProductId = currentProductId;\r\n\r\n\tif (parentProductIds == null)\r\n\t{\r\n\t\tparentProductIds = new string[0];\r\n\t}\r\n\r\n\tthis.hierarchy = parentProductIds.Reverse().Concat(new string[] { currentProductId }).ToArray();\r\n}\r\n\r\n[DataMember(Name = \"CurrentProductId\", IsRequired = true)]\r\npublic string CurrentProductId\r\n{\r\n\tget{return this.currentProductId;}\r\n\tprivate set{this.currentProductId = value;}\r\n}\r\n\r\n[DataMember(Name = \"Hierarchy\", IsRequired = true)]\r\npublic string[] Hierarchy\r\n{\r\n\tget{return this.hierarchy;}\r\n\tprivate set{this.hierarchy = value;}\r\n}\r\n\r\npublic bool IsStandalone\r\n{\r\n\tget{return this.hierarchy.First().Equals(this.currentProductId, StringComparison.InvariantCultureIgnoreCase);}\r\n}\r\n```\r\n\r\n**The C# code:**\r\n```\r\nusing (TextReader reader = File.OpenText(filePath))\r\nusing (var csv = new CsvReader(reader))\r\n{\r\n\tcsv.Configuration.RegisterClassMap<ProductHierarchyMap>();\r\n\r\n\tcsv.Configuration.PrepareHeaderForMatch = (header) => header.ToLower();\r\n\r\n\tvar records = csv.GetRecords<ProductHierarchy>().ToList();\r\n\treturn records;\r\n}\r\n```\r\n\r\n**Map class:**\r\n```\r\npublic sealed class ProductHierarchyMap : ClassMap<ProductHierarchy>\r\n{\r\n\tpublic ProductHierarchyMap()\r\n\t{\r\n\t\tAutoMap();\r\n\t\tMap(m => m.CurrentProductId).Name(\"ProductId\");\r\n\t}\r\n}\r\n```\r\n\r\nI'd appreciate any suggestions/ ideas on this."},"comment":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/comments/373266392","html_url":"https://github.com/JoshClose/CsvHelper/issues/938#issuecomment-373266392","issue_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/938","id":373266392,"user":{"login":"JoshClose","id":114971,"avatar_url":"https://avatars3.githubusercontent.com/u/114971?v=4","gravatar_id":"","url":"https://api.github.com/users/JoshClose","html_url":"https://github.com/JoshClose","followers_url":"https://api.github.com/users/JoshClose/followers","following_url":"https://api.github.com/users/JoshClose/following{/other_user}","gists_url":"https://api.github.com/users/JoshClose/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshClose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshClose/subscriptions","organizations_url":"https://api.github.com/users/JoshClose/orgs","repos_url":"https://api.github.com/users/JoshClose/repos","events_url":"https://api.github.com/users/JoshClose/events{/privacy}","received_events_url":"https://api.github.com/users/JoshClose/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T05:36:19Z","updated_at":"2018-03-15T05:36:19Z","author_association":"OWNER","body":"Currently the object creators require a parameterless constructor because they use `Expression.MemberInit`. I need to figure out a way to use `ReflectionHelper.CreateInstance` to create the object instead so the `ObjectResolver` can be used when creating the objects."}}
{"actor":{"display_login":"JoshClose"}}