I have a dbml file and dropped a Products table onto it. I now have access to the auto generated Products class file which is great.
I would like to export a CSV file's content and save it to this table, so i decided to go with Linq to CSV http://aspnetperformance.com/post/LINQ-to-CSV-library.aspx
It seems in order for the file to be read, a property needs to be decorated with an attribute i.e.
<CsvColumn(Name:= "ProductName", FieldIndex:= 1)>
But when i use the Products class it returns an error that the column name cant be found (i know this, as i created a different project which read the file without issues once the above attribute was added)
So i created a partial class and added the attribute:
<Metadatatype(GetType(ProductsMetadata))> _
Partial Public Class Products
End Class
Friend Class ProductsMetadata
<CsvColumn(Name:= "ProductName", FieldIndex:= 1)>
Public Property ProductName As String
End Class
However this still didnt work. The reason why i need to add an attribute is so when i save it i can pass in the Products object into the save method
myDataContext.Products.InsertOnSubmit(ProductObject)
myDataContext.SubmitChanges()
Is it possible to add attributes in the above manner or any other way i could do this?