private static List <Item> GetItems(string format) { List <Item> items = new List <Item>(); DbDataReader dbDataReader = GetDbReader(CommandType.StoredProcedure, "ПрайсЭкспортБезДублей"); while (dbDataReader.Read()) { Item item = new Item(); //item.Category = new Category(categories[(int)dbDataReader["Min-КодТипа"]]); if (format != "csv") { item.Category = categoryDao.FindByNumber((int)dbDataReader["Min-КодТипа"]); } item.Date = dbDataReader["Min-СрокГодн"] != DBNull.Value ? (DateTime?)dbDataReader["Min-СрокГодн"] : null; item.ProductId = (int)dbDataReader["Min-КодТовара"]; item.Manufacter = (string)dbDataReader["Min-КраткоЗаводИ"]; item.Name = (string)dbDataReader["НаимПрайс"]; item.Pack = dbDataReader["Min-Упаковка"] != DBNull.Value ? (string)dbDataReader["Min-Упаковка"] : string.Empty; item.Price1 = (decimal)dbDataReader["Min-Цена1"]; item.Price2 = (decimal)dbDataReader["Min-Цена2"]; item.Price3 = (decimal)dbDataReader["Min-Цена3"]; //item.ReceiptId = dbDataReader["Min-КодСтрокПрих"] != DBNull.Value // ? (int?)dbDataReader["Min-КодСтрокПрих"] // : null; object o = null; try { o = dbDataReader["Sum-Sum_Расход"]; if (dbDataReader["Sum-Sum_Расход"] != DBNull.Value) { item.Rest = (int?)(double)dbDataReader["Sum-Sum_Расход"]; } else { item.Rest = null; } //item.Rest = dbDataReader["Sum-Sum_Расход"] != DBNull.Value // ? (int?)dbDataReader["Sum-Sum_Расход"] // : null; } catch (Exception) { Debug.Write(o.GetType()); if (dbDataReader["Sum-Sum_Расход"] != DBNull.Value) { double d = (double)dbDataReader["Sum-Sum_Расход"]; item.Rest = (int?)d; } else { item.Rest = null; } throw; } items.Add(item); } return(items); }