/// <summary> /// 插入函数 /// </summary> /// <param name="info">Model</param> /// <returns>影响数据物理ID</returns> public long INSERT(EquipData info) { try { U_equipdata temp = new U_equipdata(); //temp.id = info.Id; temp.nid = info.Nid; temp.x = info.X; temp.y = info.Y; temp.description = info.Description; temp.type = info.Type; temp.isused = info.Isused; temp.status = info.Status; temp.logicid = info.Logicid; temp.url = info.Url; Table <U_equipdata> table = db.GetTable <U_equipdata>(); table.InsertOnSubmit(temp); db.SubmitChanges(); return(temp.id); } catch { return(-2); } }
/// <summary> /// 更新函数 /// </summary> /// <param name="info">Model</param> /// <returns>影响数据物理ID,已存在逻辑主码返回-1</returns> public long UPDATE(EquipData info) { try { U_equipdata temp = new U_equipdata(); Table <U_equipdata> table = db.GetTable <U_equipdata>(); temp = (from row in db.U_equipdata where row.id == info.Id select row).First(); //temp.id = info.Id; temp.nid = info.Nid; temp.x = info.X; temp.y = info.Y; temp.description = info.Description; temp.type = info.Type; temp.isused = info.Isused; temp.status = info.Status; temp.logicid = info.Logicid; temp.url = info.Url; db.SubmitChanges(); return(temp.id); } catch { return(-2); } }
/// <summary> /// 根据物理主码查询 /// </summary> /// <param name="id">id</param> /// <returns>结果</returns> public EquipData SELECT_BY_ID(long id) { try { EquipData rd = new EquipData(); U_equipdata temp = (from row in db.U_equipdata where row.id == id select row).First(); rd.Id = temp.id; rd.Nid = temp.nid; rd.X = temp.x; rd.Y = temp.y; rd.Description = temp.description; rd.Type = temp.type; rd.Isused = temp.isused; rd.Status = temp.status; rd.Logicid = temp.logicid; rd.Url = temp.url; return(rd); } catch { return(null); } }