You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List<MyClass>results=dataReader.ToMyClass(); // Direct method
40
44
```
41
45
42
46
Some notes for the above
43
47
44
-
* The `ToMyClass()` method above - is an `IDataReader` extension method generated at compile time. You can even "go to definition" in Visual Studio and examine its code.
45
-
* The naming convention is `ToCLASSNAME()` we can't use generics here, since `<T>` is not part of method signatures in C# (considered in later versions of C#). If you find a prettier way - please contribute!
46
-
* Maps properies with public setters only.
48
+
* The `To<MyClass>()` method above - is an `IDataReader` extension method generated at compile time.
49
+
* The naming convention is `To<T>()` where `T` is your class name marked with `[GenerateDataReaderMapper]`, e.g. `MyClass`.
50
+
* Thanks to [@5andr0](https://github.com/5andr0) for the suggestion of how to add the generic version of this method.
51
+
* The `ToMyClass()` method is functionally identical to the `To<MyClass>()` method but maintained for backwards compatability.
52
+
* The naming convention is `ToCLASSNAME()`
53
+
* You can even "go to definition" in Visual Studio and examine the code for either of these two methods.
54
+
* Maps properties with public setters only.
47
55
* The datareader is being closed after mapping, so don't reuse it.
48
56
* Supports `enum` properties based on `int` and other implicit casting (sometimes a DataReader may decide to return `byte` for small integer database value, and it maps to `int` perfectly via some unboxing magic)
49
57
* Properly maps `DBNull` to `null`.
@@ -85,10 +93,10 @@ If you're already using the awesome [Dapper ORM](https://github.com/DapperLib/Da
0 commit comments