public SqlUpdateBuild Update(Goods_tagInfo item) { return(new SqlUpdateBuild(new List <Goods_tagInfo> { item }, false) .SetGoods_id(item.Goods_id) .SetTag_id(item.Tag_id)); }
public static Goods_tagInfo Insert(Goods_tagInfo item) { item = dal.Insert(item); if (itemCacheTimeout > 0) { RemoveCache(item); } return(item); }
async public Task <Goods_tagInfo> DeleteAsync(int?Goods_id, int?Tag_id) { Goods_tagInfo item = null; await SqlHelper.ExecuteReaderAsync(async dr => { item = await BLL.Goods_tag.dal.GetItemAsync(dr); }, string.Concat(TSQL.Delete, @"[goods_id] = @goods_id AND [tag_id] = @tag_id"), new SqlParameter { ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Goods_id }, new SqlParameter { ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Tag_id }); return(item); }
async public static Task <Goods_tagInfo> InsertAsync(Goods_tagInfo item) { item = await dal.InsertAsync(item); if (itemCacheTimeout > 0) { await RemoveCacheAsync(item); } return(item); }
async public Task <APIReturn> _Add([FromForm] int?Goods_id, [FromForm] int?Tag_id) { Goods_tagInfo item = new Goods_tagInfo(); item.Goods_id = Goods_id; item.Tag_id = Tag_id; item = await Goods_tag.InsertAsync(item); return(APIReturn.成功.SetData("item", item.ToBson())); }
protected static SqlParameter[] GetParameters(Goods_tagInfo item) { return(new SqlParameter[] { new SqlParameter { ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = item.Goods_id }, new SqlParameter { ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = item.Tag_id } }); }
async public Task <ActionResult> Edit([FromQuery] int Goods_id, [FromQuery] int Tag_id) { Goods_tagInfo item = await Goods_tag.GetItemAsync(Goods_id, Tag_id); if (item == null) { return(APIReturn.记录不存在_或者没有权限); } ViewBag.item = item; return(View()); }
public Goods_tagInfo Insert(Goods_tagInfo item) { Goods_tagInfo newitem = null; SqlHelper.ExecuteReader(dr => { newitem = GetItem(dr); }, TSQL.Insert, GetParameters(item)); if (newitem == null) { return(null); } this.CopyItemAllField(item, newitem); return(item); }
async public Task <Goods_tagInfo> InsertAsync(Goods_tagInfo item) { Goods_tagInfo newitem = null; await SqlHelper.ExecuteReaderAsync(async dr => { newitem = await GetItemAsync(dr); }, TSQL.Insert, GetParameters(item)); if (newitem == null) { return(null); } this.CopyItemAllField(item, newitem); return(item); }
public Goods_tagInfo Delete(int?Goods_id, int?Tag_id) { Goods_tagInfo item = null; SqlHelper.ExecuteReader(dr => { item = BLL.Goods_tag.dal.GetItem(dr); }, string.Concat(TSQL.Delete, @"[goods_id] = @goods_id AND [tag_id] = @tag_id"), new SqlParameter { ParameterName = "@goods_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Goods_id }, new SqlParameter { ParameterName = "@tag_id", SqlDbType = SqlDbType.Int, Size = 4, Value = Tag_id }); return(item); }
async public Task <APIReturn> _Edit([FromQuery] int Goods_id, [FromQuery] int Tag_id) { Goods_tagInfo item = await Goods_tag.GetItemAsync(Goods_id, Tag_id); if (item == null) { return(APIReturn.记录不存在_或者没有权限); } int affrows = await Goods_tag.UpdateAsync(item); if (affrows > 0) { return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}")); } return(APIReturn.失败); }
public SqlUpdateBuild Update(Goods_tagInfo item, string[] ignoreFields) { var sub = new SqlUpdateBuild(new List <Goods_tagInfo> { item }, false); var ignore = ignoreFields?.ToDictionary(a => a, StringComparer.CurrentCultureIgnoreCase) ?? new Dictionary <string, string>(); if (ignore.ContainsKey("goods_id") == false) { sub.SetGoods_id(item.Goods_id); } if (ignore.ContainsKey("tag_id") == false) { sub.SetTag_id(item.Tag_id); } return(sub); }
public object GetItem(SqlDataReader dr, ref int dataIndex) { Goods_tagInfo item = new Goods_tagInfo(); if (!dr.IsDBNull(++dataIndex)) { item.Goods_id = dr.GetInt32(dataIndex); } if (item.Goods_id == null) { dataIndex += 1; return(null); } if (!dr.IsDBNull(++dataIndex)) { item.Tag_id = dr.GetInt32(dataIndex); } if (item.Tag_id == null) { dataIndex += 0; return(null); } return(item); }
async public Task <(object result, int dataIndex)> GetItemAsync(SqlDataReader dr, int dataIndex) { Goods_tagInfo item = new Goods_tagInfo(); if (!await dr.IsDBNullAsync(++dataIndex)) { item.Goods_id = await dr.GetFieldValueAsync <int>(dataIndex); } if (item.Goods_id == null) { dataIndex += 1; return(null, dataIndex); } if (!await dr.IsDBNullAsync(++dataIndex)) { item.Tag_id = await dr.GetFieldValueAsync <int>(dataIndex); } if (item.Tag_id == null) { dataIndex += 0; return(null, dataIndex); } return(item, dataIndex); }
public static string ToJson(this Goods_tagInfo item) => string.Concat(item);
private void CopyItemAllField(Goods_tagInfo item, Goods_tagInfo newitem) { item.Goods_id = newitem.Goods_id; item.Tag_id = newitem.Tag_id; }
public static int Update(Goods_tagInfo item, _ ignore1 = 0, _ ignore2 = 0, _ ignore3 = 0) => Update(item, new[] { ignore1, ignore2, ignore3 });
public static int Update(Goods_tagInfo item, _[] ignore) => dal.Update(item, ignore?.Where(a => a > 0).Select(a => Enum.GetName(typeof(_), a)).ToArray()).ExecuteNonQuery();
async public static Task <int> UpdateAsync(Goods_tagInfo item) => await dal.Update(item).ExecuteNonQueryAsync();
async internal static Task RemoveCacheAsync(Goods_tagInfo item) => await RemoveCacheAsync(item == null?null : new [] { item });
public static int Update(Goods_tagInfo item) => dal.Update(item).ExecuteNonQuery();
internal static void RemoveCache(Goods_tagInfo item) => RemoveCache(item == null ? null : new [] { item });
public static Task <int> UpdateAsync(Goods_tagInfo item, _ ignore1 = 0, _ ignore2 = 0, _ ignore3 = 0) => UpdateAsync(item, new[] { ignore1, ignore2, ignore3 });