public static bool TryAttachDefault(this IFullAuditableDbContext dbContext, object entity, out EntityEntry entry) { entry = dbContext.Entry(entity); if (entry.State == EntityState.Detached) { entry = dbContext.Attach(entity); return(true); } return(false); }
public static bool TryAttachDefault <T>(this IFullAuditableDbContext dbContext, T entity, out EntityEntry <T> entry) where T : class { entry = dbContext.Entry(entity); if (entry.State == EntityState.Detached) { entry = dbContext.Attach(entity); return(true); } return(false); }