[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class CsvRecordMapAttribute : Attribute
Namespace
CsvHelper
Assembly
CsvHelper.dll
Inheritance
object Attribute CsvRecordMapAttribute
Builds
net10.0 netstandard2.1 netstandard2.0 net47

Remarks

Each property or field of the map class stands in for the member of RecordType with the same name, and must have the same type; it only carries attributes (CsvColumnAttribute, CsvIgnoreAttribute, CsvFormatAttribute and the others), and the map class is never created. Members of the record type without a stand-in are mapped as usual, and so are the parameters of its constructor, which take the attributes of the stand-in with their name. Attributes of the record type itself, such as CsvOptionsAttribute and CsvIgnoreBaseAttribute, go on the map class, and so do the methods of CsvValidateAttribute.

The generated code uses only what the map class can access: the public (or, in the same assembly, internal) members and constructors of the record type. CsvReader.GetRecords and the other record methods find the mapper of the record type as they find those of CsvRecordAttribute types. A mapped type cannot be a nested record of another record type.

Constructors

CsvRecordMapAttribute(Type)

Added in v34.0.0
public CsvRecordMapAttribute(Type recordType)

Maps recordType with the attributes of this class's members.

Parameters

recordTypeType
The type whose records are read and written.

View source

Properties