/// <summary> /// 新增目的地 /// </summary> public static void Insert(CoDestination destination) { try { LDLLogisticsEntities context = new LDLLogisticsEntities(); //查找该目的地是否存在 if (context.CoDestination.Any(obj => obj.Code == destination.Code && obj.Valid == true)) throw new FaultException(string.Format("目的地编码[{0}]已存在!", destination.Code)); context.CoDestination.AddObject(destination); //新增 context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDestinationAdapter01", Define.Insert, destination)); //记录日志 context.SaveChanges(); //提交保存 } catch (Exception ex) { throw new FaultException(ex.Message); } }
/// <summary> /// 修改目的地 /// </summary> public static void Update(CoDestination destination) { try { LDLLogisticsEntities context = new LDLLogisticsEntities(); //查找该目的地是否存在 CoDestination _destination = context.CoDestination.FirstOrDefault(obj => obj.ID == destination.ID); if (_destination == null) throw new FaultException(string.Format("该目的地不存在!")); EntityObjectHelper.Copyto(destination, ref _destination); //利用反射动态赋值 context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDestinationAdapter03", Define.Update, _destination)); //记录日志 context.SaveChanges(); //提交保存 } catch (Exception ex) { throw new FaultException(ex.Message); } }
/// <summary> /// 用于向 CoDestination EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToCoDestination(CoDestination coDestination) { base.AddObject("CoDestination", coDestination); }
/// <summary> /// 创建新的 CoDestination 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="code">Code 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> /// <param name="siteID">SiteID 属性的初始值。</param> /// <param name="valid">Valid 属性的初始值。</param> public static CoDestination CreateCoDestination(global::System.Int32 id, global::System.String code, global::System.String name, global::System.String siteID, global::System.Boolean valid) { CoDestination coDestination = new CoDestination(); coDestination.ID = id; coDestination.Code = code; coDestination.Name = name; coDestination.SiteID = siteID; coDestination.Valid = valid; return coDestination; }
public void UpdateDestination(CoDestination destination) { CoDestinationAdapter.Update(destination); }
public void InsertDestination(CoDestination destination) { CoDestinationAdapter.Insert(destination); }