public void Update(District district) { using (DefaultCS db = new DefaultCS()) { var d = db.Districts.Where(i => i.Id == district.Id).First(); d.DistrictName = district.DistrictName; db.SaveChanges(); } }
public void Add(District district) { using (DefaultCS db = new DefaultCS()) { db.Districts.MergeOption = MergeOption.NoTracking; db.Districts.AddObject(district); db.SaveChanges(); } }
/// <summary> /// Deprecated Method for adding a new object to the Districts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDistricts(District district) { base.AddObject("Districts", district); }
/// <summary> /// Create a new District object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="districtName">Initial value of the DistrictName property.</param> public static District CreateDistrict(global::System.Int32 id, global::System.String districtName) { District district = new District(); district.Id = id; district.DistrictName = districtName; return district; }