/// <summary>
        /// Circle.
        /// </summary>

        internal static String ToCircle(NpgsqlNativeTypeInfo TypeInfo, Object NativeData, Boolean ForExtendedQuery)
        {
            NpgsqlCircle C = (NpgsqlCircle)NativeData;

            return(String.Format(CultureInfo.InvariantCulture, "{0},{1},{2}", C.Center.X, C.Center.Y, C.Radius));
        }
예제 #2
0
        /// <summary>
        /// Circle.
        /// </summary>
        internal static byte[] ToCircle(NpgsqlNativeTypeInfo TypeInfo, Object NativeData, Boolean forExtendedQuery, NativeToBackendTypeConverterOptions options, bool arrayElement)
        {
            NpgsqlCircle C = (NpgsqlCircle)NativeData;

            return(BackendEncoding.UTF8Encoding.GetBytes(String.Format(CultureInfo.InvariantCulture, "{0},{1},{2}", C.Center.X, C.Center.Y, C.Radius)));
        }
예제 #3
0
        public void Circle()
        {
            var expected = new NpgsqlCircle(1, 2, 0.5);
            var cmd = new NpgsqlCommand("SELECT @p1, @p2", Conn);
            var p1 = new NpgsqlParameter("p1", NpgsqlDbType.Circle) { Value = expected };
            var p2 = new NpgsqlParameter { ParameterName = "p2", Value = expected };
            Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.Circle));
            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(NpgsqlCircle)));
                Assert.That(reader[i], Is.EqualTo(expected));
            }
        }
예제 #4
0
        public void Circle()
        {
            using (var conn = OpenConnection())
            {
                var expected = new NpgsqlCircle(1, 2, 0.5);
                var cmd = new NpgsqlCommand("SELECT @p1, @p2", conn);
                var p1 = new NpgsqlParameter("p1", NpgsqlDbType.Circle) {Value = expected};
                var p2 = new NpgsqlParameter {ParameterName = "p2", Value = expected};
                Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.Circle));
                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(NpgsqlCircle)));
                        var actual = reader.GetFieldValue<NpgsqlCircle>(i);
                        Assert.That(actual.X, Is.EqualTo(expected.X).Within(1).Ulps);
                        Assert.That(actual.Y, Is.EqualTo(expected.Y).Within(1).Ulps);
                        Assert.That(actual.Radius, Is.EqualTo(expected.Radius).Within(1).Ulps);
                    }
                }
            }
        }