private bool CreateStateAssociation(Mode mode, int itemID) { var returnCode = false; var association = (from ModeState ms in _db.ModeStates where ms.ModeID == mode.ModeID && ms.StateID == itemID select ms).FirstOrDefault(); // If not found, then we create it if(association == null) { returnCode = true; association = new ModeState(); association.ModeID = mode.ModeID; association.StateID = itemID; _db.ModeStates.AddObject(association); SaveChanges(); } return returnCode; }
/// <summary> /// Deprecated Method for adding a new object to the ModeStates EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToModeStates(ModeState modeState) { base.AddObject("ModeStates", modeState); }
/// <summary> /// Create a new ModeState object. /// </summary> /// <param name="modeStateID">Initial value of the ModeStateID property.</param> /// <param name="modeID">Initial value of the ModeID property.</param> /// <param name="stateID">Initial value of the StateID property.</param> public static ModeState CreateModeState(global::System.Int32 modeStateID, global::System.Int32 modeID, global::System.Int32 stateID) { ModeState modeState = new ModeState(); modeState.ModeStateID = modeStateID; modeState.ModeID = modeID; modeState.StateID = stateID; return modeState; }