public bool Update(tb_MetaProduct entity) { try { db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); return(true); } catch { return(false); } }
public void SaveValue(string Key, string Value, long Id) { var meta = db.tb_MetaProduct.Where(x => x.Key == Key && x.ProductId == Id).SingleOrDefault(); if (meta == null) { meta = new tb_MetaProduct(); meta.ProductId = Id; meta.Key = Key; meta.Value = Value; db.tb_MetaProduct.Add(meta); db.SaveChanges(); } else { meta.ProductId = Id; meta.Key = Key; meta.Value = Value; db.Entry(meta).State = EntityState.Modified; db.SaveChanges(); } }
public long Insert(tb_MetaProduct entity) { db.tb_MetaProduct.Add(entity); db.SaveChanges(); return(entity.Id); }