public static async void SomeOtherTest() { var id = new Guid("d834d9bc-12f9-47a2-80c1-58c65eddfa14"); var c1 = new SQLiteAsyncConnection(Client1DB.SampleDatabasePath(), true); var c2 = new SQLiteAsyncConnection(Client1DB.SampleDatabasePath(), true); var a = await c1.Table <AggregateEvent>().Where(x => x.Identity == id).FirstAsync(); var b = await c1.Table <AggregateEvent>().Where(x => x.Identity == id).FirstAsync(); // a.Version = 1; // var t1 = c1.UpdateAsync(a); // a.Version = 2; // var t2 = c1.UpdateAsync(a); var t1 = c1.Table <AggregateEvent>().ToListAsync(); var t2 = c1.Table <AggregateEvent>().ToListAsync(); await Task.WhenAll(t1, t2); Console.WriteLine("{0} on thread {1}", t1.Result.Count + t2.Result.Count, Thread.CurrentThread.ManagedThreadId); }
public static void InitSample() { if (Remote == null) { TestId = Guid.NewGuid(); var eventSerializer = new DataContractSerializer <EventBase>(TypeHelpers.FindSerializableTypes(typeof(EventBase), Assembly.GetCallingAssembly())); var commandSerializer = new DataContractSerializer <CommandBase>(TypeHelpers.FindSerializableTypes(typeof(CommandBase), Assembly.GetCallingAssembly())); Remote = new EventSourcedDomainContext(RemoteDB.SampleDatabasePath(), eventSerializer); Client1 = new EventSourcedDomainContext(Client1DB.SampleDatabasePath(), ReadModelDB1.SampleDatabasePath(), eventSerializer) { CommandSerializer = commandSerializer }; Client2 = new EventSourcedDomainContext(Client2DB.SampleDatabasePath(), ReadModelDB2.SampleDatabasePath(), eventSerializer) { CommandSerializer = commandSerializer }; var registration = AggregateRegistration.ForType <EventSourcedRoot>(); // .WithImmediateReadModel(c => new TransactionReadModelBuilder(new SqlRepository<TransactionDataContract>(EventSourcedDB.Main, "TestId"))); Client1.Register(registration.WithDelayedReadModel( // TODO: pass in read model db as a scope scope => new TransactionReadModelBuilder(new SqlRepository <TransactionDataContract>(scope, "TestId")))); Client1.StartDelayedReadModels(); Client2.Register(registration); } }