public int Add(T t) { context.Set <T>().Add(t); context.Set <T>().Distinct(); try { return(context.SaveChanges()); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { var cls = validationErrors.Entry.Entity.GetType().FullName; var prop = validationError.PropertyName; var errmsg = validationError.ErrorMessage; Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } throw; } //return null; }
public OlympicsAsiaGenericRepository(OCASIAMeetingContext context) { this.context = context; this.dbset = context.Set <T>(); this.context.Configuration.LazyLoadingEnabled = false; }