/// <summary> /// 根据物理主码查询 /// </summary> /// <param name="id">id</param> /// <returns>结果</returns> public LanType SELECT_BY_ID(long id) { try { LanType rd = new LanType(); S_lantype temp = (from row in db.S_lantype where row.id == id select row).First(); rd.Id = temp.id; rd.Name = temp.name; rd.Sort = temp.sort; rd.Isused = temp.isused; return(rd); } catch { return(null); } }
/// <summary> /// 插入函数 /// </summary> /// <param name="info">Model</param> /// <returns>影响数据物理ID</returns> public long INSERT(LanType info) { try { S_lantype temp = new S_lantype(); //temp.id = info.Id; temp.name = info.Name; temp.sort = info.Sort; temp.isused = info.Isused; Table <S_lantype> table = db.GetTable <S_lantype>(); 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(LanType info) { try { S_lantype temp = new S_lantype(); Table <S_lantype> table = db.GetTable <S_lantype>(); temp = (from row in db.S_lantype where row.id == info.Id select row).First(); //temp.id = info.Id; temp.name = info.Name; temp.sort = info.Sort; temp.isused = info.Isused; db.SubmitChanges(); return(temp.id); } catch { return(-2); } }