/// <summary> /// 新增一条收藏 /// </summary> /// <param name="channelDetailInfo"></param> /// <returns></returns> public bool InsertRecord(ChannelDetailInfo channelDetailInfo) { try { DBFavourInfo dbFavourInfo = GetRowByVID(channelDetailInfo.VID); if (dbFavourInfo != null) return false; dbFavourInfo = new DBFavourInfo(channelDetailInfo); _dataContext.Table_DBFavourInfo.InsertOnSubmit(dbFavourInfo); _dataContext.SubmitChanges(); return true; } catch (Exception exception) { string message = exception.Message; return false; } }
/// <summary> /// 根据ID获取某条收藏记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public DBFavourInfo GetRowByID(int id) { DBFavourInfo dbFavourInfo = new DBFavourInfo(); var query = from toSelect in GetAllRows() where toSelect.ID == id select toSelect; foreach (var s in query) { dbFavourInfo = s; } return dbFavourInfo; }