public void Line() { var expected = new NpgsqlLine(1, 2, 3); var cmd = new NpgsqlCommand("SELECT @p1, @p2", Conn); var p1 = new NpgsqlParameter("p1", NpgsqlDbType.Line) { Value = expected }; var p2 = new NpgsqlParameter { ParameterName = "p2", Value = expected }; Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.Line)); 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(0), Is.EqualTo(typeof(NpgsqlLine))); Assert.That(reader[i], Is.EqualTo(expected)); } }
private object YieldJToken(Type ctype, JToken jt, int rank) { if (rank == 0) { if (ctype == typeof_BitArray) { return(Executer.Parse1010(jt.ToString())); } if (ctype == typeof_NpgsqlPoint) { return(NpgsqlPoint.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlLine) { return(NpgsqlLine.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlLSeg) { return(NpgsqlLSeg.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlBox) { return(NpgsqlBox.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlPath) { return(NpgsqlPath.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlPolygon) { return(NpgsqlPolygon.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlCircle) { return(NpgsqlCircle.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlInet) { return(new NpgsqlInet(jt.ToString())); } if (ctype == typeof_IPAddress) { return(new NpgsqlInet(jt.ToString())); } if (ctype == typeof_PhysicalAddress) { return(PhysicalAddress.Parse(jt.ToString())); } if (ctype == typeof_NpgsqlRange_int) { return(Executer.ParseNpgsqlRange <int>(jt.ToString())); } if (ctype == typeof_NpgsqlRange_long) { return(Executer.ParseNpgsqlRange <long>(jt.ToString())); } if (ctype == typeof_NpgsqlRange_decimal) { return(Executer.ParseNpgsqlRange <decimal>(jt.ToString())); } if (ctype == typeof_NpgsqlRange_DateTime) { return(Executer.ParseNpgsqlRange <DateTime>(jt.ToString())); } return(null); } return(jt.Select <JToken, object>(a => YieldJToken(ctype, a, rank - 1))); }
public void Line() { var expected = new NpgsqlLine(1, 2, 3); var cmd = new NpgsqlCommand("SELECT @p1, @p2", Conn); var p1 = new NpgsqlParameter("p1", NpgsqlDbType.Line) { Value = expected }; var p2 = new NpgsqlParameter { ParameterName = "p2", Value = expected }; Assert.That(p2.NpgsqlDbType, Is.EqualTo(NpgsqlDbType.Line)); 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(0), Is.EqualTo(typeof(NpgsqlLine))); Assert.That(reader[i], Is.EqualTo(expected)); } }