示例#1
0
        static async Task Main(string[] args)
        {
            new DatabaseCreator().CreateDatabase();

            using (var nhibernateConfigurator = new CoreDddSampleNhibernateConfigurator())
            {
                await new PersistNewEntitySample().PersistNewEntity(nhibernateConfigurator);

                await new QuerySample().QueryShipsByName(nhibernateConfigurator);
                await new QueryWithQueryExecutorSample().QueryShipsByName(nhibernateConfigurator);

                await new CommandSample().CreateNewShip(nhibernateConfigurator);
                await new CommandWithCommandExecutorSample().CreateNewShip(nhibernateConfigurator);

                await new DddSample()
                .BuildAndPersistPolicyEntitiesAndExecuteDomainBehaviourOnThemAndExecuteQueriesOverThem(
                    nhibernateConfigurator,
                    isDelayedDomainEventHandlingEnabled: false     // immediate domain event handling when raised
                    );
                await new DddSample()
                .BuildAndPersistPolicyEntitiesAndExecuteDomainBehaviourOnThemAndExecuteQueriesOverThem(
                    nhibernateConfigurator,
                    isDelayedDomainEventHandlingEnabled: true     // delayed domain event handling, domain event handlers are executed manually by calling DomainEvents.RaiseDelayedEvents();
                    );
            }

            await new QueryWithIoCContainerSample().QueryShipsByName();
            await new QueryWithIoCContainerAndQueryExecutorDependencyInjectionSample().QueryShipsByName();
            await new QueryWithBatchingSample().QueryShipsByMultipleNames();

            await new CommandWithIoCContainerSample().CreateNewShip();
            await new CommandWithIoCContainerAndCommandExecutorDependencyInjectionSample().CreateNewShip();
            await new CommandWithDomainBehaviourExecutedOnExistingAggregateRootEntitySample().UpdateShipData();
        }
示例#2
0
        public void CreateDatabase()
        {
            using (var nhibernateConfigurator = new CoreDddSampleNhibernateConfigurator(shouldMapDtos: false))
            {
                var configuration    = nhibernateConfigurator.GetConfiguration();
                var connectionString = configuration.Properties["connection.connection_string"];

                using (var connection = new SQLiteConnection(connectionString))
                {
                    connection.Open();
                    new DatabaseSchemaCreator().CreateDatabaseSchema(nhibernateConfigurator, connection);
                    _CreateDtoViews(connection);
                }
            }
        }