/// <summary> /// 创建一个一对多中的多 /// </summary> /// <param name="db">实体数据</param> /// <param name="entity">将要创建的一个一对多中的多</param> public void Create(SysEntities db, YiDuiDuoZhongDeDuo entity) { if (entity != null) { db.YiDuiDuoZhongDeDuo.AddObject(entity); } }
/// <summary> /// 创建一个一对多中的多 /// </summary> /// <param name="entity">一个对象</param> /// <returns></returns> public int Create(YiDuiDuoZhongDeDuo entity) { using (SysEntities db = new SysEntities()) { Create(db, entity); return(this.Save(db)); } }
/// <summary> /// 删除一个一对多中的多 /// </summary> /// <param name="db">实体数据</param> /// <param name="id">一条一对多中的多的主键</param> public void Delete(SysEntities db, int id) { YiDuiDuoZhongDeDuo deleteItem = GetById(db, id); if (deleteItem != null) { db.YiDuiDuoZhongDeDuo.DeleteObject(deleteItem); } }
/// <summary> /// 编辑一个一对多中的多对象 /// </summary> /// <param name="db">实体数据</param> /// <param name="entity">将要编辑的一个一对多中的多对象</param> public YiDuiDuoZhongDeDuo Edit(SysEntities db, YiDuiDuoZhongDeDuo entity) { db.YiDuiDuoZhongDeDuo.Attach(entity); db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(entity); }