1 // created on 18/5/2002 at 01:25
3 // Npgsql.NpgsqlParameter.cs
6 // Francisco Jr. (fxjrlists@yahoo.com.br)
8 // Copyright (C) 2002 The Npgsql Development Team
9 // npgsql-general@gborg.postgresql.org
10 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 /// This class represents a parameter to a command that will be sent to server
37 public sealed class NpgsqlParameter : IDbDataParameter, IDataParameter
40 // Logging related values
41 private static readonly String CLASSNAME = "NpgsqlParameter";
43 // Fields to implement IDbDataParameter interface.
44 private byte precision;
48 // Fields to implement IDataParameter
49 private DbType db_type;
50 private ParameterDirection direction;
51 private Boolean is_nullable;
53 private String source_column;
54 private DataRowVersion source_version;
60 // [TODO] Implement other constructors.
62 public NpgsqlParameter()
67 public NpgsqlParameter(String parameterName, DbType parameterType)
70 if (name[0] != ':') // Support both ':'paramname and paramname constructions.
73 db_type = parameterType;
77 public NpgsqlParameter(String parameterName, DbType parameterType, Int32 size, String sourceColumn)
80 if (name[0] != ':') // Support both ':'paramname and paramname constructions.
82 db_type = parameterType;
84 source_column = sourceColumn;
85 direction = ParameterDirection.Input;
87 // Implementation of IDbDataParameter
99 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".Precision = " + value, LogLevel.Normal);
113 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".Scale = " + value, LogLevel.Normal);
127 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".Size = " + value, LogLevel.Normal);
138 // [TODO] Validate data type.
142 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".DbType = " + value, LogLevel.Normal);
148 public ParameterDirection Direction
152 NpgsqlEventLog.LogMsg("Get " + CLASSNAME + ".Direction", LogLevel.Normal);
159 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".Direction = " + value, LogLevel.Normal);
163 public Boolean IsNullable
173 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".IsNullable = " + value, LogLevel.Normal);
177 public String ParameterName
181 NpgsqlEventLog.LogMsg("Get " + CLASSNAME + ".ParameterName", LogLevel.Normal);
190 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".ParameterName = " + value, LogLevel.Normal);
194 public String SourceColumn
198 NpgsqlEventLog.LogMsg(CLASSNAME + ".get_SourceColumn" + value, LogLevel.Normal);
199 return source_column;
204 source_column = value;
205 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".SourceColumn = " + value, LogLevel.Normal);
209 public DataRowVersion SourceVersion
213 NpgsqlEventLog.LogMsg(CLASSNAME + ".get_SourceVersion = " + value, LogLevel.Normal);
214 return source_version;
219 source_version = value;
220 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".SourceVersion = " + value, LogLevel.Normal);
228 NpgsqlEventLog.LogMsg("Get " + CLASSNAME + ".Value", LogLevel.Normal);
232 // [TODO] Check and validate data type.
236 NpgsqlEventLog.LogMsg("Set " + CLASSNAME + ".Value", LogLevel.Normal);