public List<Product> getList()
{
using (NpgsqlConnection connection = getConnection())
{
using (NpgsqlCommand cmd = new NpgsqlCommand(SELECT_CMD, connection))
{
connection.Open();
List<Product> result = new List<Product>();
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Product temp = new Product();
temp.id = reader.GetGuid(0);
temp.description = reader.GetString(1);
temp.productGroupID = reader.GetGuid(2);
temp.Unit = Units.FromName(reader.GetString(3));
if (!reader.IsDBNull(4))
{
temp.weight = (Decimal)reader.GetFloat(4);
}
temp.money = reader.GetDecimal(5);
temp.quantity = reader.GetInt32(6);
result.Add(temp);
}
}
return result;
}
}
}