Example #1
0
        public static void Install(IServiceCollection serviceCollection, String keyspace, params String[] contactPoints)
        {
            serviceCollection.AddSingleton <Mappings, CassandraMappings>();
            serviceCollection.AddSingleton <ICluster>(provider => Cluster.Builder().AddContactPoints(contactPoints).Build());

            serviceCollection.AddSingleton <IUnitOfWork>(provider =>
            {
                var unitOfWork = new CassandraUnitOfWork(provider.GetRequiredService <ICluster>(), provider.GetRequiredService <Mappings>(),
                                                         keyspace);

                // Map UDTs (just UDTs, not entities with their own tables)
                var session = unitOfWork.Session;
                session.UserDefinedTypes.Define(UdtMap.For <L7PduEntity>(),
                                                UdtMap.For <IPEndPointEntity>(),
                                                UdtMap.For <DnsExportEntity.DnsQueryEntity>(),
                                                UdtMap.For <DnsExportEntity.DnsAnswerEntity>());

                return(unitOfWork);
            });

            EntityRepositoriesServiceInstaller.InstallEntityRepositories(serviceCollection, typeof(BaseRepository <>));
        }
Example #2
0
 public static void Install(IServiceCollection serviceCollection)
 {
     EntityRepositoriesServiceInstaller.InstallUnitOfWork(serviceCollection, typeof(InMemoryUnitOfWork));
     EntityRepositoriesServiceInstaller.InstallEntityRepositories(serviceCollection, typeof(BaseRepository <>));
 }