protected override void PrepareInsertUpdateCommand(DbCommand command, FoodOrderPending foodOrderPending) { SqlCommand sqlCommand = (SqlCommand)command; sqlCommand.Parameters.Add("@p_priority", SqlDbType.VarChar).Value = foodOrderPending.Priority.ToString(); sqlCommand.Parameters.Add("@p_start_date", SqlDbType.Date).Value = foodOrderPending.StartDate; sqlCommand.Parameters.Add("@p_resolved_date", SqlDbType.Date).Value = foodOrderPending.ResolvedDate; sqlCommand.Parameters.Add("@p_id", SqlDbType.Int).Value = foodOrderPending.Id; sqlCommand.Parameters.Add("@p_food_id", SqlDbType.Int).Value = foodOrderPending.Food.Id; }
public int Insert(FoodOrderPending foodOrderPending) { db.Connect(); DbCommand command = db.CreateCommand(GetInsertSql()); PrepareInsertUpdateCommand(command, foodOrderPending); int ret = db.ExecuteNonQuery(command); db.Close(); return(ret); }
protected override void PrepareInsertUpdateCommand(DbCommand command, FoodOrderPending foodOrderPending) { OracleCommand oracleCommand = (OracleCommand)command; oracleCommand.BindByName = true; oracleCommand.Parameters.Add("p_priority", OracleDbType.Varchar2).Value = foodOrderPending.Priority.ToString(); oracleCommand.Parameters.Add("p_start_date", OracleDbType.Date).Value = foodOrderPending.StartDate; oracleCommand.Parameters.Add("p_resolved_date", OracleDbType.Date).Value = foodOrderPending.ResolvedDate; oracleCommand.Parameters.Add("p_id", OracleDbType.Int32).Value = foodOrderPending.Id; oracleCommand.Parameters.Add("p_food_id", OracleDbType.Int32).Value = foodOrderPending.Food.Id; }
protected override IList <FoodOrderPending> Read(DbDataReader reader) { IList <FoodOrderPending> foodOrderPendings = new List <FoodOrderPending>(); SqlDataReader sqlReader = (SqlDataReader)reader; while (sqlReader.Read()) { int i = -1; FoodOrderPending foodOrderPending = new FoodOrderPending(); foodOrderPending.Id = sqlReader.GetInt32(++i); foodOrderPending.StartDate = sqlReader.GetDateTime(++i); if (!sqlReader.IsDBNull(++i)) { foodOrderPending.ResolvedDate = sqlReader.GetDateTime(i); } foodOrderPending.Priority = FoodOrderPriorityEnumUtils.getPriority(sqlReader.GetString(++i)); foodOrderPending.Food = new Food(); foodOrderPending.Food = new Food(); foodOrderPending.Food.Id = sqlReader.GetInt32(++i); foodOrderPending.Food.Name = sqlReader.GetString(++i); foodOrderPending.Food.Price = (double)sqlReader.GetDecimal(++i); foodOrderPending.Food.Proteins = sqlReader.GetInt32(++i); foodOrderPending.Food.Carbohydrates = sqlReader.GetInt32(++i); foodOrderPending.Food.Fat = sqlReader.GetInt32(++i); foodOrderPending.Food.FoodRunningOut = sqlReader.GetBoolean(++i); foodOrderPending.Food.Company = new Company(); foodOrderPending.Food.Company.Id = sqlReader.GetInt32(++i); foodOrderPendings.Add(foodOrderPending); } return(foodOrderPendings); }
protected override IList <FoodOrderPending> Read(DbDataReader reader) { IList <FoodOrderPending> foodOrderPendings = new List <FoodOrderPending>(); OracleDataReader oracleReader = (OracleDataReader)reader; while (oracleReader.Read()) { int i = -1; FoodOrderPending foodOrderPending = new FoodOrderPending(); foodOrderPending.Id = oracleReader.GetInt32(++i); foodOrderPending.StartDate = oracleReader.GetDateTime(++i); if (!oracleReader.IsDBNull(++i)) { foodOrderPending.ResolvedDate = oracleReader.GetDateTime(i); } foodOrderPending.Priority = FoodOrderPriorityEnumUtils.getPriority(oracleReader.GetString(++i)); foodOrderPending.Food = new Food(); foodOrderPending.Food = new Food(); foodOrderPending.Food.Id = oracleReader.GetInt32(++i); foodOrderPending.Food.Name = oracleReader.GetString(++i); foodOrderPending.Food.Price = oracleReader.GetDouble(++i); foodOrderPending.Food.Proteins = oracleReader.GetInt32(++i); foodOrderPending.Food.Carbohydrates = oracleReader.GetInt32(++i); foodOrderPending.Food.Fat = oracleReader.GetInt32(++i); foodOrderPending.Food.FoodRunningOut = oracleReader.GetString(++i) == "1" ? true : false; foodOrderPending.Food.Company = new Company(); foodOrderPending.Food.Company.Id = oracleReader.GetInt32(++i); foodOrderPendings.Add(foodOrderPending); } return(foodOrderPendings); }
protected abstract void PrepareInsertUpdateCommand(DbCommand command, FoodOrderPending foodOrderPending);