summaryrefslogtreecommitdiff
path: root/ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-05-12 09:24:40 +0800
committerchai <215380520@qq.com>2023-05-12 09:24:40 +0800
commit2a1cd4fda8a4a8e649910d16b4dfa1ce7ae63543 (patch)
treea471fafed72e80b4ac3ac3002e06c34220dd6058 /ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties
parentb8a694746562b37dc8dc5b8b5aec8612bb0964fc (diff)
*misc
Diffstat (limited to 'ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties')
-rw-r--r--ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties/index.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties/index.md b/ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties/index.md
new file mode 100644
index 0000000..df6719d
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/src/CsvHelper.Website/input/examples/configuration/class-maps/ignoring-properties/index.md
@@ -0,0 +1,40 @@
+# Ignoring Properties
+
+When you use auto mapping in your class map, every property will get mapped. If there are properties that you don't want mapped, you can ignore them.
+
+###### Data
+
+```
+Id,Name
+1,one
+```
+
+###### Example
+
+```cs
+void Main()
+{
+ using (var reader = new StreamReader("path\\to\\file.csv"))
+ using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>();
+ }
+}
+
+public class Foo
+{
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public bool IsDirty { get; set; }
+}
+
+public sealed class FooMap : ClassMap<Foo>
+{
+ public FooMap()
+ {
+ AutoMap(CultureInfo.InvariantCulture);
+ Map(m => m.IsDirty).Ignore();
+ }
+}
+```