src/EntityFramework.SqlServer/SqlSpatialDataReader.cs
// <summary>
// Builds and compiles the Expression equivalent of the following:
// (BinaryReader r) => { var result = new SpatialType(); result.Read(r); return r; }
// The construct/read pattern is preferred over casting the result of calling GetValue on the DataReader,
// because constructing the value directly allows client code to specify the type, rather than SqlClient using
// the server-specified assembly qualified type name from TDS to try to locate the correct type on the client.
// </summary>
Builds and compiles the Expression equivalent of the following:
(BinaryReader r) => { var result = new SpatialType(); result.Read(r); return r; }
The construct/read pattern is preferred over casting the result of calling GetValue on the DataReader,
because constructing the value directly allows client code to specify the type, rather than SqlClient using
the server-specified assembly qualified type name from TDS to try to locate the correct type on the client.
Builds and compiles the Expression equivalent of the following : ( BinaryReader r ) = > { var result = new SpatialType () ; result . Read ( r ) ; return r ; } The construct / read pattern is preferred over casting the result of calling GetValue on the DataReader because constructing the value directly allows client code to specify the type rather than SqlClient using the server - specified assembly qualified type name from TDS to try to locate the correct type on the client .
private static Func<BinaryReader, object> CreateBinaryReadDelegate(Type spatialType)
        {
            DebugCheck.NotNull(spatialType);
            var readerParam = Expression.Parameter(typeof(BinaryReader));
            var binarySerializable = Expression.Variable(spatialType);
            var readMethod = spatialType.GetPublicInstanceMethod("Read", typeof(BinaryReader));
            var ex = Expression.Lambda<Func<BinaryReader, object>>(
                Expression.Block(
                    new[] { binarySerializable },
                    Expression.Assign(binarySerializable, Expression.New(spatialType)),
                    Expression.Call(binarySerializable, readMethod, readerParam),
                    binarySerializable
                    ),
                readerParam
                );
            var result = ex.Compile();
            return result;
        }
private static Func < BinaryReader , object > CreateBinaryReadDelegate ( Type spatialType ) { DebugCheck . NotNull ( spatialType ) ; var readerParam = Expression . Parameter ( typeof ( BinaryReader ) ) ; var binarySerializable = Expression . Variable ( spatialType ) ; var readMethod = spatialType . GetPublicInstanceMethod ( " " , typeof ( BinaryReader ) ) ; var ex = Expression . Lambda < Func < BinaryReader , object > > ( Expression . Block ( new [ ] { binarySerializable } , Expression . Assign ( binarySerializable , Expression . New ( spatialType ) ) , Expression . Call ( binarySerializable , readMethod , readerParam ) , binarySerializable ) , readerParam ) ; var result = ex . Compile ( ) ; return result ; }
Builds and compiles the Expression equivalent of the following:
(BinaryReader r) => { var result = new SpatialType(); result.Read(r); return r; }
The construct/read pattern is preferred over casting the result of calling GetValue on the DataReader,
because constructing the value directly allows client code to specify the type, rather than SqlClient using
the server-specified assembly qualified type name from TDS to try to locate the correct type on the client.
Builds and compiles the Expression equivalent of the following : ( BinaryReader r ) = > { var result = new SpatialType () ; result . Read ( r ) ; return r ; } The construct / read pattern is preferred over casting the result of calling GetValue on the DataReader because constructing the value directly allows client code to specify the type rather than SqlClient using the server - specified assembly qualified type name from TDS to try to locate the correct type on the client .
spatialType
Type