public static List<IPlant> load_plants(Ground parent,kindstatus status) { DPLANT dna = new DPLANT(); List<IPlant> List = new List<IPlant>(); List<DPLANT> query; if(status == kindstatus.Growup || status ==kindstatus.Reproduction){ query = Context.DPLANT.Where(S => S.PARENT_ID == parent.GroundID && !S.STATUS.Contains( kindstatus.Seed.ToString()) ).ToList(); } else{ query = Context.DPLANT.Where(S => S.PARENT_ID == parent.GroundID && S.STATUS.Contains( kindstatus.Seed.ToString()) ).ToList(); } foreach (DPLANT item in query) { Plant newplant = new Plant(parent, item.aliveID); newplant.CurrentLifeCycle = (int)item.CURRENTLIFECYCLE; newplant.Generation = (int)item.GENERATION; newplant.NextReproductionCycle = (int)item.NEXTREPRODUCTIONCYCLE; newplant.Size = (int)item.SIZE; newplant.Waterdeposit = (int)item.WATERDEPOSIT; switch (item.STATUS) { case "Seed": newplant.Status = kindstatus.Seed; break; case "Growup": newplant.Status = kindstatus.Growup; break; case "Reproduction": newplant.Status = kindstatus.Reproduction; break; } List.Add(newplant); } return List; }
/// <summary> /// Create a new DPLANT object. /// </summary> /// <param name="aliveID">Initial value of the aliveID property.</param> public static DPLANT CreateDPLANT(global::System.String aliveID) { DPLANT dPLANT = new DPLANT(); dPLANT.aliveID = aliveID; return dPLANT; }
public static void save_plant(Plant Plant) { DPLANT plant = new DPLANT(); plant.PARENT_ID = Plant.Parent; plant.aliveID = Plant.AliveID; plant.CURRENTLIFECYCLE = Plant.CurrentLifeCycle; plant.GENERATION = Plant.Generation; plant.SIZE = (int) Plant.Size; plant.STATUS = Plant.Status.ToString(); plant.WATERDEPOSIT = Plant.Waterdeposit; plant.NEXTREPRODUCTIONCYCLE = Plant.NextReproductionCycle; Context.AddToDPLANT(plant); Console.WriteLine(Context.SaveChanges()); }
/// <summary> /// Deprecated Method for adding a new object to the DPLANT EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDPLANT(DPLANT dPLANT) { base.AddObject("DPLANT", dPLANT); }