codeice / linqtoexcel

Automatically exported from code.google.com/p/linqtoexcel
0 stars 0 forks source link

Provide alternative to expressions for providing column mappings #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The API does not provide a means by which columns can be simply mapped by 
property name. Use of expressions means I am unable to do something like:

excel.AddMapping<MyRecord>("FirstName", "First Name");

more precisely I am doing:
foreach (var propertyInfo in typeof(FieldDefinition).GetProperties()) {
   //Code to get column name from LINQ To SQL ColumnAttribute
   var columnAttribute = propertyInfo
                    .GetCustomAttributes(typeof (ColumnAttribute), true)
                    .OfType<ColumnAttribute>()
                    .FirstOrDefault();
  excel.AddMapping(propertyInfo.Name, columnAttribute.Name);
  //OR
  excel.AddMapping(propertyInfo, columnAttribute.Name);
}            

Original issue reported on code.google.com by DamR...@gmail.com on 1 Apr 2011 at 9:30

GoogleCodeExporter commented 8 years ago
This feature has been added in version 1.5.3 You can install it through NuGet 
or download it from the project website.

Original comment by paulyo...@gmail.com on 23 May 2011 at 4:23

GoogleCodeExporter commented 8 years ago
Thanks. I had resorted to using reflection of the underlying dictionary prior 
to this fix. Thanks.

Original comment by DamR...@gmail.com on 23 May 2011 at 4:39