public static void InsertOnSubmit(this DbSet<Forum> source, Forum forum) { if (forum.ForumID == default(int)) { // New entity source.Add(forum); } else { // Existing entity source.Attach(forum); } }
public static void DeleteOnSubmit(this DbSet<Forum> source, Forum forum) { source.Remove(forum); }