public ReturnType AddItemPropValue(List <ItemPropValue> itempropvalueList) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { foreach (ItemPropValue itempropvalue in itempropvalueList) { Alading.Entity.ItemPropValue dbpropvalue = alading.ItemPropValue.FirstOrDefault(p => p.cid == itempropvalue.cid && p.pid == itempropvalue.pid && p.vid == itempropvalue.vid); if (dbpropvalue == null) { alading.AddToItemPropValue(itempropvalue); } } alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType AddItemPropValue(ItemPropValue itempropvalue) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { Alading.Entity.ItemPropValue DBpropvalue = alading.ItemPropValue.Where(p => p.cid == itempropvalue.cid && p.pid == itempropvalue.pid && p.vid == itempropvalue.vid).FirstOrDefault(); if (DBpropvalue == null) { alading.AddToItemPropValue(itempropvalue); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.SaveFailed); } } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }