use ordinal
This commit is contained in:
13
DbService.cs
13
DbService.cs
@ -61,18 +61,19 @@ namespace de.hottis.genericdatabaseapiservice.Services {
|
||||
Console.WriteLine("Output Property name: {0} {1} ", propertyInfo.Name, propertyInfo.PropertyType);
|
||||
var attributes = propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), true);
|
||||
var dma = (DataMemberAttribute)attributes[0];
|
||||
Console.WriteLine("Output DataMember name: {0} {1} ", dma.Name, dma.TypeId);
|
||||
int ordinal = reader.GetOrdinal(dma.Name);
|
||||
Console.WriteLine("Output DataMember name: {0} {1} {2} ", dma.Name, dma.TypeId, ordinal);
|
||||
if (propertyInfo.PropertyType == typeof(System.String)) {
|
||||
if (reader.IsDBNull(dma.Name)) {
|
||||
if (reader.IsDBNull(ordinal)) {
|
||||
propertyInfo.SetValue(item, null);
|
||||
Console.WriteLine("Output Value: null");
|
||||
} else {
|
||||
propertyInfo.SetValue(item, reader.GetString(dma.Name));
|
||||
Console.WriteLine("Output Value:{0}", reader.GetString(dma.Name));
|
||||
propertyInfo.SetValue(item, reader.GetString(ordinal));
|
||||
Console.WriteLine("Output Value:{0}", reader.GetString(ordinal));
|
||||
}
|
||||
} else if (propertyInfo.PropertyType == typeof(System.Int32)) {
|
||||
propertyInfo.SetValue(item, reader.GetInt32(dma.Name));
|
||||
Console.WriteLine("Output Value:{0}", reader.GetInt32(dma.Name));
|
||||
propertyInfo.SetValue(item, reader.GetInt32(ordinal));
|
||||
Console.WriteLine("Output Value:{0}", reader.GetInt32(ordinal));
|
||||
}
|
||||
}
|
||||
itemList.Add(item);
|
||||
|
Reference in New Issue
Block a user