public void Load(int personEntityId) { using (var ctx = new accountingEntities()) { var person = ctx.people .Where(x => x.ID.Equals(personEntityId)) .SingleOrDefault(); PERSON = person; if (person == null) throw new Exception("no such a Person Exists"); } }
public void New(string firstName,string lastName) { using (var ctx = new accountingEntities()) { var checkDuplication = ctx.people.Where(x => x.firstname == firstName && x.lastname == lastName).FirstOrDefault(); if (checkDuplication != null) throw new Exception("Person Duplicated"); var newPerson = new person() { firstname=firstName, lastname=lastName, ID = base.ENTITY.ID }; ctx.people.AddObject(newPerson); ctx.SaveChanges(); this.PERSON = newPerson; } }
/// <summary> /// Create a new person object. /// </summary> /// <param name="id">Initial value of the ID property.</param> public static person Createperson(global::System.Int32 id) { person person = new person(); person.ID = id; return person; }
/// <summary> /// Deprecated Method for adding a new object to the people EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTopeople(person person) { base.AddObject("people", person); }