public T MapSingle(QueryResult queryResult) { var ord = queryResult.GetOrdinal(_aliasName); if (queryResult.IsDBNull(ord)) { return(default(T)); } if (typeof(T).IsEnum) { return((T)(object)QueryTypeReaders.GetTypeReader <int>()(queryResult, ord)); } return(QueryTypeReaders.GetTypeReader <T>()(queryResult, ord)); }
public T ReadField <T>(SqlStorageField <TEntity> field) { var ord = _queryResult.GetOrdinal(field.FieldName); if (_queryResult.IsDBNull(ord)) { return(default(T)); } if (typeof(T).IsEnum) { return((T)(object)QueryTypeReaders.GetTypeReader <int>()(_queryResult, ord)); } var reader = QueryTypeReaders.GetTypeReader <T>(); if (reader == null) { throw new System.InvalidOperationException("Attempting to read an unsupported data type from query result."); } return(reader(_queryResult, ord)); }