+2004-09-14 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
+
+ * Npgsql/NpgsqlRowDescription.cs:
+ FieldIndex: Added support for case insensitive fields index lookup. Thanks Martin ( martijn at boland dot org)
+
2004-09-12 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
* NpgsqlTypes/NpgsqlTypesHelper:
public void ReadFromStream(Stream input_stream, Encoding encoding, NpgsqlBackendTypeMapping type_mapping)
{
- switch (protocol_version) {
+ switch (protocol_version)
+ {
case ProtocolVersion.Version2 :
ReadFromStream_Ver_2(input_stream, encoding, type_mapping);
break;
public Int16 FieldIndex(String fieldName)
{
- Int16 result = 0;
+ Int16 result = -1;
+
+ // First try to find the index with IndexOf (case-sensitive)
+ result = (Int16)fields_index.IndexOf(fieldName);
- foreach (String name in fields_index)
+ if (result > -1)
+ {
+ return result;
+ }
+ else
{
- if (name.Equals(fieldName))
+ result = 0;
+ foreach (String name in fields_index)
{
- return result;
+
+ if (name.Equals(fieldName))
+ {
+ return result;
+ }
+ result++;
}
- result++;
+
}
+
+ throw new ArgumentOutOfRangeException("fieldName", fieldName, "Field name not found");
- throw new ArgumentOutOfRangeException("fieldName", fieldName, "Field name not found");
}
}
-
-}
+}
\ No newline at end of file