我一直運行到這個錯誤:CsvReaderException了未處理
An unhandled exception of type 'CsvHelper.CsvReaderException' occurred in CsvHelper.dll
Additional information: No properties are mapped for type 'RPS_String_Parse.Program+FormattedRow'.
但我相信我是正確的以下the documentation。引用 「入門」 部分後,我實現了這一點:
和我的課:
public class FormattedRow
{
public string IDOrderAlpha;
public string IDOrder;
public string AddressCompany;
public string Address1;
public string Address2;
public string AddressCity;
public string AddressState;
public string AddressZip;
public string AddressCountry;
public string ShipMethod;
public string ContactEmail;
public string ContactName;
public string ServiceRep;
public string CustomerPuchaseOrder;
}
我覺得這應該工作,因爲文檔狀態:
Auto Mapping
If you don't supply a mapping file, auto mapping will be used. Auto mapping will map the properties in your class in the order they appear in. If the property is a custom class, it recursively maps the properties from that class in the order they appear in. If the auto mapper hits a circular reference, it will stop going down that reference branch
我錯過了什麼?
我跑到相同的錯誤,但我有{get;組;)。你需要做其他事情來解決這個問題嗎? –
只是使它成爲我的財產,但它必須是公共財產。如果所有屬性都標記爲內部或私人,則會導致相同的錯誤消息。 –
根據我的經驗,AutoMapper似乎需要使用CSV標頭來匹配字段名稱,而不是按索引進行映射。 – scotru