public void InsertOrUpdate(ALLERGY allergy) { if (allergy.ALLERGYID == default(int)) // New entity { _context.Entry(allergy).State = EntityState.Added; } else // Existing entity { _context.Entry(allergy).State = EntityState.Modified; } }
public void InsertOrUpdateGraph(ALLERGY allergyGraph) { if (allergyGraph.State == DOCVIDEO.ObjectState.State.Added) { _context.Allergies.Add(allergyGraph); } else { _context.Allergies.Add(allergyGraph); _context.ApplyStateChanges(); } }