Skip to content

Instantly share code, notes, and snippets.

@yreynhout
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yreynhout/6f1a356306a96221d441 to your computer and use it in GitHub Desktop.
Save yreynhout/6f1a356306a96221d441 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<system.data>
<DbProviderFactories>
<add name="SQLite Data Provider" invariant="System.Data.SQLite"
description="ADO.NET Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
</configuration>
class Program
{
static void Main(string[] args)
{
var stores = new List<string>
{
"user_eventstore",
"registration_eventstore",
"project_eventstore",
"authentication_eventstore",
}
.Select(CreateStore)
.ToList();
using (var stream = stores[0].CreateStream(Guid.NewGuid()))
{
stream.Add(new EventMessage
{
Body = new object()
});
stream.Add(new EventMessage
{
Body = new object()
});
stream.CommitChanges(Guid.NewGuid());
}
var storeCounts = stores.Select(x => x.Advanced.GetFrom(null))
.SelectMany(x => x)
.SelectMany(x => x.Events)
.ToList();
var total = storeCounts.Count(); // 40 instead of 10
Console.WriteLine(total);
Console.ReadLine();
}
private static IStoreEvents CreateStore(string name)
{
var file = Path.Combine(Environment.CurrentDirectory, name + ".db");
var connectionString = string.Format("Data Source={0};Version=3;UseUTF16Encoding=True;",file);
if(!File.Exists(file)) SQLiteConnection.CreateFile(file);
return Wireup
.Init()
.UsingSqlPersistence(name, "System.Data.SQLite", connectionString)
.WithDialect(new SqliteDialect())
.InitializeStorageEngine()
.Build();
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NEventStore" version="5.1.0" targetFramework="net451" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net451" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment