Ciągle działa w ten błąd:CsvReaderException był nieobsługiwany
An unhandled exception of type 'CsvHelper.CsvReaderException' occurred in CsvHelper.dll
Additional information: No properties are mapped for type 'RPS_String_Parse.Program+FormattedRow'.
Ale wierzę śledzę the documentation poprawnie. Po przedstawieniu w "Getting Started" część I wdrożone następująco:
using (var sr = new StreamReader(filePath))
{
var csv = new CsvReader(sr);
var records = csv.GetRecords<FormattedRow>();
foreach (var record in records)
{
Console.WriteLine(record.Address1);
}
Console.ReadLine();
}
i moja klasa:
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;
}
czuję się jak to powinno działać, ponieważ stanach dokumentacja:
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
czego mi brakuje?
Używam tego samego błędu, ale mam {get; zestaw;). Czy musisz zrobić cokolwiek innego, aby rozwiązać problem? –
Po prostu sprawienie, by działka była dla mnie dobra, ale musi to być własność publiczna. Jeśli wszystkie właściwości są oznaczone jako wewnętrzne lub prywatne, spowoduje to ten sam komunikat o błędzie. –
Z mojego doświadczenia wynika, że AutoMapper wydaje się wymagać, aby nagłówki CSV pasowały do nazw pól zamiast mapowania według indeksu. – scotru