Beispiel #1
0
        public TProperty GetSpatialPropertyValueWithErrorHandling <TProperty>(
            int ordinal, string propertyName, string typeName, PrimitiveTypeKind spatialTypeKind)
        {
            TProperty result;

            if (Helper.IsGeographicTypeKind(spatialTypeKind))
            {
                result = new PropertyErrorHandlingValueReader <TProperty>(
                    propertyName, typeName,
                    (reader, column) => (TProperty)(object)_spatialReader.Value.GetGeography(column),
                    (reader, column) => _spatialReader.Value.GetGeography(column)
                    ).GetValue(Reader, ordinal);
            }
            else
            {
                Debug.Assert(Helper.IsGeometricTypeKind(spatialTypeKind));
                result = new PropertyErrorHandlingValueReader <TProperty>(
                    propertyName, typeName,
                    (reader, column) => (TProperty)(object)_spatialReader.Value.GetGeometry(column),
                    (reader, column) => _spatialReader.Value.GetGeometry(column)
                    ).GetValue(Reader, ordinal);
            }

            return(result);
        }
Beispiel #2
0
        // <summary>
        // Used to retrieve a property value with exception handling. Normally compiled
        // delegates directly call typed methods on the DbDataReader (e.g. GetInt32)
        // but when an exception occurs we retry using this method to potentially get
        // a more useful error message to the user.
        // </summary>
        public TProperty GetPropertyValueWithErrorHandling <TProperty>(int ordinal, string propertyName, string typeName)
        {
            var result = new PropertyErrorHandlingValueReader <TProperty>(propertyName, typeName).GetValue(Reader, ordinal);

            return(result);
        }