/// <summary> /// Create a new State object. /// </summary> /// <param name="stateID">Initial value of the StateID property.</param> /// <param name="stateName">Initial value of the StateName property.</param> /// <param name="countryID">Initial value of the CountryID property.</param> public static State CreateState(global::System.Int32 stateID, global::System.String stateName, global::System.Int32 countryID) { State state = new State(); state.StateID = stateID; state.StateName = stateName; state.CountryID = countryID; return state; }
/// <summary> /// Deprecated Method for adding a new object to the States EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToStates(State state) { base.AddObject("States", state); }
private Int32 AddState(string stateName,int countryId) { var states = entities.States; foreach (var i in states) { if (String.Equals(i.StateName.ToLower(), stateName.Trim().ToLower())) { return i.StateID; } } State newState = new State(); newState.StateName= stateName.Trim(); newState.CountryID = countryId; entities.States.AddObject(newState); entities.SaveChanges(); return newState.StateID; }