From 2a1cd4fda8a4a8e649910d16b4dfa1ce7ae63543 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 12 May 2023 09:24:40 +0800 Subject: *misc --- .../reading/enumerate-class-records/index.html | 457 +++++++++++++++++++++ 1 file changed, 457 insertions(+) create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html (limited to 'ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html') diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html new file mode 100644 index 0000000..4102d5d --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/enumerate-class-records/index.html @@ -0,0 +1,457 @@ + + + + + + + + + + + + + + + + + + + + + + + Enumerate Class Records | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Enumerate Class Records

+

Convert CSV rows into a class object that is re-used on every iteration of the enumerable. Each enumeration will hydrate the given record, but only the mapped members. If you supplied a map and didn't map one of the members, that member will not get hydrated with the current row's data. Be careful. Any methods that you call on the projection that force the evaluation of the IEnumerable, such as ToList(), you will get a list where all the records are the same instance you provided that is hydrated with the last record in the CSV file.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+		var record = new Foo();
+        var records = csv.EnumerateRecords(record);
+		foreach (var r in records)
+		{
+			// r is the same instance as record.
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + -- cgit v1.1-26-g67d0