{"action":"created","issue":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/719","repository_url":"https://api.github.com/repos/JoshClose/CsvHelper","labels_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/719/labels{/name}","comments_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/719/comments","events_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/719/events","html_url":"https://github.com/JoshClose/CsvHelper/issues/719","id":245909027,"number":719,"title":"Runtime mapping example for 3.0?","user":{"login":"sereeth","id":16249946,"avatar_url":"https://avatars3.githubusercontent.com/u/16249946?v=4","gravatar_id":"","url":"https://api.github.com/users/sereeth","html_url":"https://github.com/sereeth","followers_url":"https://api.github.com/users/sereeth/followers","following_url":"https://api.github.com/users/sereeth/following{/other_user}","gists_url":"https://api.github.com/users/sereeth/gists{/gist_id}","starred_url":"https://api.github.com/users/sereeth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sereeth/subscriptions","organizations_url":"https://api.github.com/users/sereeth/orgs","repos_url":"https://api.github.com/users/sereeth/repos","events_url":"https://api.github.com/users/sereeth/events{/privacy}","received_events_url":"https://api.github.com/users/sereeth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-27T02:34:54Z","updated_at":"2017-08-21T17:43:38Z","closed_at":null,"body":"Are there any examples of runtime mappings for 3.0 since the docs are way out of date.  I'm looking to do something like read a dictionary of property name to column name, and create a map from that.  Maps would be stored in a database, so for each customer a different map can be created to read their files."},"comment":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/comments/323807471","html_url":"https://github.com/JoshClose/CsvHelper/issues/719#issuecomment-323807471","issue_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/719","id":323807471,"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":"2017-08-21T17:43:38Z","updated_at":"2017-08-21T17:43:38Z","body":"I don't know all of the criteria you have, but here is one way.\r\n\r\n```cs\r\nvoid Main()\r\n{\r\n\tusing (var stream = new MemoryStream())\r\n\tusing (var writer = new StreamWriter(stream))\r\n\tusing (var reader = new StreamReader(stream))\r\n\tusing (var csv = new CsvReader(reader))\r\n\t{\r\n\t\twriter.WriteLine(\"IdField,NameField\");\r\n\t\twriter.WriteLine(\"1,one\");\r\n\t\twriter.WriteLine(\"2,two\");\r\n\t\twriter.Flush();\r\n\t\tstream.Position = 0;\r\n\r\n\t\tvar dict = new Dictionary<string, string>\r\n\t\t{\r\n\t\t\t{ \"IdField\", \"Id\" },\r\n\t\t\t{ \"NameField\", \"Name\" }\r\n\t\t};\r\n\r\n\t\tvar map = new DefaultCsvClassMap<Test>();\r\n\t\tforeach (var pair in dict)\r\n\t\t{\r\n\t\t\tvar property = typeof(Test).GetProperty(pair.Value);\r\n\t\t\tvar propertyMap = CsvPropertyMap.CreateGeneric(typeof(Test), property);\r\n\t\t\tpropertyMap.Data.Names.Add(pair.Key);\r\n\t\t\tmap.PropertyMaps.Add(propertyMap);\r\n\t\t}\r\n\t\tcsv.Configuration.RegisterClassMap(map);\r\n\t\tcsv.GetRecords<Test>().Dump();\r\n\t}\r\n}\r\n\r\npublic class Test\r\n{\r\n\tpublic int Id { get; set; }\r\n\tpublic string Name { get; set; }\r\n}\r\n```"}}
{"actor":{"display_login":"JoshClose"}}