Created
October 25, 2014 12:37
-
-
Save htoooth/122f0ff596082ccac576 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class RecordExtensions | |
| { | |
| private static class Cache<T> | |
| { | |
| public static Func<IDataRecord,int, T> Get; | |
| } | |
| static RecordExtensions() | |
| { | |
| Cache<string>.Get = (record, field) => record.GetString(field); | |
| Cache<int>.Get = (record, field) => record.GetInt32(field); | |
| Cache<long>.Get = (record, field) => record.GetInt64(field); | |
| Cache<float>.Get = (record, field) => record.GetFloat(field); | |
| Cache<double>.Get = (record, field) => record.GetDouble(field); | |
| } | |
| public static T Get<T>(this IDataRecord record, int field) | |
| { | |
| return Cache<T>.Get(record, field); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment