debugging

This commit is contained in:
2021-12-02 15:57:58 +01:00
parent b5d20b185f
commit 959b36760a
3 changed files with 18 additions and 8 deletions

View File

@ -14,8 +14,9 @@ namespace de.hottis.genericdatabaseapiservice.Services {
}
public class DbServiceException : Exception {}
public class NotDataFoundException : DbServiceException {}
public class NoDataFoundException : DbServiceException {}
public class TooMuchDataFoundException : DbServiceException {}
public class UnsupportedDataTypeException: DbServiceException {}
public class DbService : IDbService {
private readonly IConfiguration Configuration;
@ -68,11 +69,15 @@ namespace de.hottis.genericdatabaseapiservice.Services {
propertyInfo.SetValue(item, null);
Console.WriteLine("Output Value: null");
} else if (propertyInfo.PropertyType == typeof(System.String)) {
propertyInfo.SetValue(item, reader.GetString(ordinal));
Console.WriteLine("Output Value:{0}", reader.GetString(ordinal));
var value = reader.GetString(ordinal);
propertyInfo.SetValue(item, value);
Console.WriteLine("Output Value:{0}", value);
} else if (propertyInfo.PropertyType == typeof(System.Int32)) {
propertyInfo.SetValue(item, reader.GetInt32(ordinal));
Console.WriteLine("Output Value:{0}", reader.GetInt32(ordinal));
var value = reader.GetInt32(ordinal);
propertyInfo.SetValue(item, value);
Console.WriteLine("Output Value:{0}", value);
} else {
throw new UnsupportedDataTypeException();
}
}
itemList.Add(item);
@ -82,7 +87,7 @@ namespace de.hottis.genericdatabaseapiservice.Services {
}
if (itemList.Count == 0) {
throw new NotDataFoundException();
throw new NoDataFoundException();
}
if (justOne && itemList.Count > 1) {
throw new TooMuchDataFoundException();