Closed davezych closed 8 years ago
you can use EntityFramework CodeFirst to create the tables for you. The user should provide the database provider and connection strings. This way you are database agnostic.
You just need an initializer:
public class MyDbContext : DbContext
{
public IDbSet<Foo> Foos { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Database.SetInitializer(new MyDbContextInitializer());
base.OnModelCreating(modelBuilder);
}
}
public class MyDbContextInitializer : DropCreateDatabaseIfModelChanges<MyDbContext>
{
protected override void Seed(MyDbContext dbContext)
{
// seed data
base.Seed(dbContext);
}
}
Note: because this has external dependencies, it should be put into an external library.
another thing: we might not want to ship a database provider, because the user probably has its own database scheme that he wants to use. usually, the user would just provide an adapter method to his logging facility (ie. NLog, Serilog, etc.).
This way, the developer/administrator can configure where the output should go to by setting an appropriate logging appender.
@MovGP0 should we remove IPublisher
and SetPublisher
and just use the New<TResult>([NotNull]string name, [NotNull]Action<ExperimentResult<TResult>> publish)
overload? The more I think about it, the more I don't see a need for a global publisher. Passing in a lambda is easy, and for more complicated publishing passing a static method works great, such as:
static void MyPublish(ExperimentResult<bool> result)
{
//whatever
}
var science = Shience.New<bool>("test", MyPublish);
This also avoids having to implement various publishers, since users can easily specify their own.
yes, I agree with that. The user should provide his own publisher logic. It would also solve some issues with thread safety and unit testing.
:+1: I'll close this and open a new issue to track removing SetPublisher
.
Implement publisher for databases.
Things to consider: