/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public GeometryValueConverter(Type type, SqlServerSpatialReader reader) : base( (Expression <Func <IGeometry, SqlBytes> >)(g => new SqlBytes(_writer.Write(g))), GetConvertFromProviderExpression(type, reader)) { ModelClrType = type; }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public SqlServerGeometryTypeMapping(Type clrType, SqlServerSpatialReader reader, string storeType) : base( new RelationalTypeMappingParameters( new CoreTypeMappingParameters( clrType, new GeometryValueConverter(clrType, reader), new GeometryValueComparer(clrType)), storeType)) { _reader = reader; }
private static LambdaExpression GetConvertFromProviderExpression(Type type, SqlServerSpatialReader reader) { var bytes = Expression.Parameter(typeof(SqlBytes), "bytes"); Expression body = Expression.Call( Expression.Constant(reader), typeof(SqlServerSpatialReader).GetRuntimeMethod(nameof(SqlServerSpatialReader.Read), new[] { typeof(byte[]) }), new[] { Expression.Property(bytes, nameof(SqlBytes.Value)) }); if (!type.IsAssignableFrom(typeof(IGeometry))) { body = Expression.Convert(body, type); } return(Expression.Lambda(body, bytes)); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public SqlServerNTSTypeMappingSourcePlugin([NotNull] IGeometryServices geometryServices) { Check.NotNull(geometryServices, nameof(geometryServices)); _reader = new SqlServerSpatialReader(geometryServices); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public GeometryValueConverter(SqlServerSpatialReader reader) : base( g => new SqlBytes(_writer.Write(g)), b => (TGeometry)reader.Read(b.Value)) { }
public SqlServerGeometryTypeMapping(SqlServerSpatialReader reader, string storeType) : base(new GeometryValueConverter <TGeometry>(reader), storeType) { }