Exemplo n.º 1
0
        public void LineSegment()
        {
            using (var conn = OpenConnection())
            {
                var expected = new NpgsqlLSeg(1, 2, 3, 4);
                var cmd = new NpgsqlCommand("SELECT @p1, @p2", conn);
                var p1 = new NpgsqlParameter("p1", NpgsqlDbType.LSeg) {Value = expected};
                var p2 = new NpgsqlParameter {ParameterName = "p2", Value = expected};
                Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.LSeg));
                cmd.Parameters.Add(p1);
                cmd.Parameters.Add(p2);
                using (var reader = cmd.ExecuteReader())
                {
                    reader.Read();

                    for (var i = 0; i < cmd.Parameters.Count; i++)
                    {
                        Assert.That(reader.GetFieldType(i), Is.EqualTo(typeof(NpgsqlLSeg)));
                        var actual = reader.GetFieldValue<NpgsqlLSeg>(i);
                        AssertPointsEqual(actual.Start, expected.Start);
                        AssertPointsEqual(actual.End, expected.End);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void LineSegment()
        {
            var expected = new NpgsqlLSeg(1, 2 ,3, 4);
            var cmd = new NpgsqlCommand("SELECT @p1, @p2", Conn);
            var p1 = new NpgsqlParameter("p1", NpgsqlDbType.LSeg) { Value = expected };
            var p2 = new NpgsqlParameter { ParameterName = "p2", Value = expected };
            Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.LSeg));
            cmd.Parameters.Add(p1);
            cmd.Parameters.Add(p2);
            var reader = cmd.ExecuteReader();
            reader.Read();

            for (var i = 0; i < cmd.Parameters.Count; i++) {
                Assert.That(reader.GetFieldType(i), Is.EqualTo(typeof(NpgsqlLSeg)));
                Assert.That(reader[i], Is.EqualTo(expected));
            }
        }
        /// <summary>
        /// LSeg.
        /// </summary>

        internal static String ToLSeg(NpgsqlNativeTypeInfo TypeInfo, Object NativeData, Boolean ForExtendedQuery)
        {
            NpgsqlLSeg S = (NpgsqlLSeg)NativeData;

            return(String.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", S.Start.X, S.Start.Y, S.End.X, S.End.Y));
        }
Exemplo n.º 4
0
        /// <summary>
        /// LSeg.
        /// </summary>
        internal static byte[] ToLSeg(NpgsqlNativeTypeInfo TypeInfo, Object NativeData, Boolean forExtendedQuery, NativeToBackendTypeConverterOptions options, bool arrayElement)
        {
            NpgsqlLSeg S = (NpgsqlLSeg)NativeData;

            return(BackendEncoding.UTF8Encoding.GetBytes(String.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", S.Start.X, S.Start.Y, S.End.X, S.End.Y)));
        }