/// <summary> /// 增加一条记录 /// </summary> /// <param name="entity">实体模型</param> /// <returns></returns> public virtual bool Add(U_AwardEntity entity) { if (entity.ID <= 0) { entity.ID = GetNewID(); } Dictionary <string, object> dict = new Dictionary <string, object>(); GetParameters(entity, dict); string strSQL = "insert into U_Award (" + "ID," + "Weight," + "Number) " + "values(" + "@ID," + "@Weight," + "@Number)"; return(_DB.ExeSQLResult(strSQL, dict)); }
/// <summary> /// 把实体类转换成键/值对集合 /// </summary> /// <param name="entity"></param> /// <param name="dict"></param> private static void GetParameters(U_AwardEntity entity, Dictionary <string, object> dict) { dict.Add("ID", entity.ID); dict.Add("Weight", entity.Weight); dict.Add("Number", entity.Number); }
/// <summary> /// 增加或更新一条记录(异步方式) /// </summary> /// <param name="entity">实体模型</param> /// <param name="IsSave">是否增加</param> /// <returns></returns> public virtual async Task <bool> AddOrUpdateAsync(U_AwardEntity entity, bool IsSave) { return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity)); }
/// <summary> /// 增加或更新一条记录 /// </summary> /// <param name="entity">实体模型</param> /// <param name="IsSave">是否增加</param> /// <returns></returns> public virtual bool AddOrUpdate(U_AwardEntity entity, bool IsSave) { return(IsSave ? Add(entity) : Update(entity)); }