/// <summary>
        /// Compiles and executes the Query against the databasecontext
        /// </summary>
        /// <param name="context">The database context</param>
        public void Execute(IDatabaseContext context)
        {
            var expr = context.ConnectionProvider.QueryCompiler;

            var query = expr.Compile(QueryParts, context.Interceptors);
            context.Kernel.Execute(query);
        }
Exemple #2
0
        internal Database(DatabaseSystem system, IDatabaseContext context)
        {
            System = system;
            Context = context;

            Name = Context.DatabaseName();

            DiscoverDataVersion();

            TableComposite = new TableSourceComposite(this);

            Context.RegisterInstance(this);
            Context.RegisterInstance<ITableSourceComposite>(TableComposite);

            Locker = new Locker(this);

            Sessions = new ActiveSessionList(this);

            // Create the single row table
            var t = new TemporaryTable(context, "SINGLE_ROW_TABLE", new ColumnInfo[0]);
            t.NewRow();
            SingleRowTable = t;

            TransactionFactory = new DatabaseTransactionFactory(this);
        }
 protected AccountBasedManagement(IDatabaseContext context, int personId, int accountId)
     : base(context, personId)
 {
     var permission = MyPermissions.Single(x => x.Key.Id == accountId);
     AccountGroup = permission.Key;
     AccountGroupPermission = permission.Value;
 }
Exemple #4
0
        public UnitOfWork(IDatabaseContext context)
        {
            _context = context;
            _context.OpenConnection();

            _transaction = _context.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
        }
 public ApiKeyManagement(IDatabaseContext context, int personId, int accountId)
     : base(context, personId, accountId)
 {
     if (!CanDoStuff)
     {
         throw new UnauthorizedAccessException("You are not an administrative user.");
     }
 }
 protected UserRestrictedDatabaseLink(IDatabaseContext context, int personId)
     : base(context)
 {
     //TODO: Only admins can reactivate their account.
     _person = Context.List<Person>().Single(x =>
         x.Id == personId
         && !x.DisabledDate.HasValue);
 }
        public TransactionContext(IDatabaseContext databaseContext)
            : base(databaseContext)
        {
            VariableManager = new VariableManager(this);
            CursorManager = new CursorManager(this);

            EventRegistry = new TransactionRegistry(this);
        }
Exemple #8
0
        protected virtual IDatabase CreateDatabase(IDatabaseContext context)
        {
            var database = new Database(context);
            database.Create(AdminUserName, AdminPassword);
            database.Open();

            return database;
        }
Exemple #9
0
        public LogService(long subscriptionId, IDatabaseContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Database = context;
            SubscriptionId = subscriptionId;
        }
        public SystemRoutineProvider(IDatabaseContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Context = context;
            resolvers = new Dictionary<Type, IRoutineResolver>();
        }
Exemple #11
0
        public ProjectContext(IDatabaseContext context, long projectId)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Database = context;
            ProjectId = projectId;
            Errors = new List<Tuple<string, string>>();
        }
        public SingleFileStoreSystem(IDatabaseContext context, IConfiguration configuration)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            this.context = context;

            Configure(configuration);

            OpenOrCreateFile();
        }
 public Collector(IDatabaseContext context)
 {
     _context = context;   
     Items = new ItemRepository(_context);
     Ingredients = new IngredientRepository(_context);
     Foodplans = new FoodplanRepository(_context);
     Shoppinglists = new ShoppinglistRepository(_context);
     Recipes = new RecipeRepository(_context);
     Users = new UserRepository(_context); 
             
 }
 public CreateSaleCommand(
     IDateService dateService,
     IDatabaseContext database,
     ISaleFactory factory,
     IInventoryClient client)
 {
     _dateService = dateService;
     _database = database;
     _factory = factory;
     _client = client;
 }
        public static void InitializeNHibernate(params Assembly[] assemblies)
        {
            if (SessionFactory != null)
                return;

            Console.WriteLine("Creating a new SessionFactory");

#if SQLEXPRESS

            SessionFactory = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2000
                              .ConnectionString(
                              c =>
                              c.Is(
                                  @"Data Source=.\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True;Pooling=False"))
                              .ShowSql())
                .Mappings(m => Array.ForEach(assemblies, a => m.FluentMappings.AddFromAssembly(a)))
                .ExposeConfiguration(configuration =>
                    {
                        configuration.SetProperty("current_session_context_class", "call");
                        Configuration = configuration;
                    })
                .BuildSessionFactory();
#endif

#if SQLITE

            SessionFactory = Fluently.Configure()
                .Database(SQLiteConfiguration.Standard
                              .InMemory()
                              .ShowSql())
                .Mappings(m => Array.ForEach(assemblies, a => m.FluentMappings.AddFromAssembly(a)))
                .ExposeConfiguration(configuration =>
                    {
                        configuration.SetProperty("current_session_context_class", "call");
                        Configuration = configuration;
                    })
                .BuildSessionFactory();

#endif


            DatabaseContext = new NHibernateDatabaseContext(new NHibernateSessionContextManager(SessionFactory), SessionFactory);

            var session = SessionFactory.OpenSession();
            CurrentSessionContext.Bind(session);

            // Export Schema
            new SchemaExport(Configuration).Execute( /* script to console is */ false,
                /* export to database is */ true,
                /* drop only is */ false, session.Connection,
                /* TextWriter is */ null);
        }
        public void SetUp_for_tests()
        {
            // Create mock for Unit of work
            mockData = Substitute.For<IDatabaseContext>();

            mockData.DbSetIngredients.Returns(inMemoryIngredients);
            
    

            _testCollector = new Collector(mockData);
            
            

        }
        public void SetUp()
        {
            var builder = new ContainerBuilder();

            _ravenDbContext = MockRepository.GenerateStub<IDatabaseContext>();
            
            var stubDocumentSession = MockRepository.GenerateStub<IDocumentSession>();
            _ravenDbContext.Stub(x => x.OpenSession()).Return(stubDocumentSession);

            builder.RegisterInstance(_ravenDbContext).As<IDatabaseContext>();
            builder.RegisterModule<DatabaseSessionModule>();
            
            base.BuildAndCreateTestDependencyResolver(builder);
        }
Exemple #18
0
        public Database(IDatabaseContext context)
        {
            DatabaseContext = context;

            DiscoverDataVersion();

            TableComposite = new TableSourceComposite(this);

            // Create the single row table
            var t = new TemporaryTable(context, "SINGLE_ROW_TABLE", new ColumnInfo[0]);
            t.NewRow();
            SingleRowTable = t;

            TransactionFactory = new DatabaseTransactionFactory(this);
        }
Exemple #19
0
        public void TestSetup()
        {
            systemContext = new SystemContext();

            var test = TestContext.CurrentContext.Test.Name;
            if (test != "CreateNewContext") {
                databaseContext = new DatabaseContext(systemContext, TestDbName);
            }

            if (test != "CreateNew" &&
                test != "DatabaseNotExists" &&
                test != "CreateNewContext") {
                database = new Database(databaseContext);
                database.Create(TestAdminUser, TestAdminPass);
                database.Open();
            }
        }
Exemple #20
0
        private static void Log(string message, LogEntryLevel level, long subscriptionId, IDatabaseContext context = null)
        {
            var log = new Log
            {
                SubscriptionId = subscriptionId,
                Message = message,
                Level = level
            };

            if (context != null)
            {
                Log(log, context);
            }
            else
            {
                using (var newContext = new DatabaseContext())
                {
                    Log(log, newContext);
                }
            }
        }
Exemple #21
0
        private static void Log(Exception exception, LogEntryLevel level, long subscriptionId, IDatabaseContext context = null)
        {
            var log = new Log
            {
                SubscriptionId = subscriptionId,
                Message = exception.Message,
                Level = level,
                Source = exception.Source,
                StackTrace = exception.StackTrace
            };

            if (context != null)
            {
                Log(log, context);
            }
            else
            {
                using (var newContext = new DatabaseContext())
                {
                    Log(log, newContext);
                }
            }
        }
		public ProductReviewRepository(IDatabaseContext databaseContext)
		{
			_databaseContext = databaseContext;
		}
Exemple #23
0
 public GetSpecificationAttributeQueryHandler(IDatabaseContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #24
0
 /// <summary>
 /// Construct a <see cref="UserController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/></param>
 /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/></param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/>.</param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public UserController(IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, ISystemIdentityFactory systemIdentityFactory, ICryptographySuite cryptographySuite, ILogger <UserController> logger, IOptions <GeneralConfiguration> generalConfigurationOptions) : base(databaseContext, authenticationContextFactory, logger, false, true)
 {
     this.systemIdentityFactory = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory));
     this.cryptographySuite     = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
     generalConfiguration       = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Exemple #25
0
 public RiderRepository(IDatabaseContext databaseContext, ICountryRepository countryRepository)
 {
     _context           = databaseContext;
     _countryRepository = countryRepository;
 }
Exemple #26
0
 public NotifyDataAccess(IDatabaseContext databaseContext, IMapper mapper)
 => (this.databaseContext, this.mapper) = (databaseContext, mapper);
 public RecurringExpenseRepository(IDatabaseContext conn, LogService logService, ICreditCardRepository creditCardRepository) : base(conn, logService)
 {
     _creditCardRepository = creditCardRepository;
 }
 public RepositoryFactory(IDatabaseContext database)
 {
     _database = database;
 }
Exemple #29
0
 public PatientsController(IDatabaseContext patientContext)
 {
     PatientContext = patientContext;
 }
 public GetAllCategoriesQueryHandler(IDatabaseContext context)
 {
     _context = context;
 }
Exemple #31
0
 public async Task <bool> DeleteFromDatabase(IDatabaseContext database)
 {
     return(await database.DeleteEntityAsync(Entity));
 }
Exemple #32
0
        public async Task <bool> UpdateInDatabase(IDatabaseContext database)
        {
            Entity.OnUpdateInDatabase();

            return(await database.UpdateAsync(Entity));
        }
 public UserRolRepository(IDatabaseContext database) : base(database)
 {
 }
 public BackgroundManager(IDatabaseContext context)
     : base(context)
 {
     //maybe do some form of authentication??
 }
 /// <summary>
 /// Construct a <see cref="ByondController"/>
 /// </summary>
 /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param>
 /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param>
 /// <param name="instanceManager">The value of <see cref="instanceManager"/></param>
 /// <param name="jobManager">The value of <see cref="jobManager"/></param>
 /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param>
 public ByondController(IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, IInstanceManager instanceManager, IJobManager jobManager, ILogger <ByondController> logger) : base(databaseContext, authenticationContextFactory, logger, true)
 {
     this.instanceManager = instanceManager ?? throw new ArgumentNullException(nameof(instanceManager));
     this.jobManager      = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
 }
Exemple #36
0
 public UserRepository(IDatabaseContext dbContext)
     : base(dbContext)
 {
 }
Exemple #37
0
 public StoryRepository(IDatabaseContext context) : base(context)
 {
 }
Exemple #38
0
 public SOProduceRepository(IDatabaseContext databaseContext)
     : base(databaseContext)
 {
 }
Exemple #39
0
 public CompanyService(IDatabaseContext context)
 {
     _companyRepository = new CompanyRepository(context);
     _userRepository    = new UserRepository(context);
 }
 public ChannelEventRepository(IDatabaseContext context)
 {
     _context = context;
 }
 protected BaseRepository(IDatabaseContext databaseContext)
 {
     DatabaseContext = databaseContext;
 }
 public User[] SendNotifications(IDatabaseContext ctx, IEntryWithNames entry, IEnumerable <Artist> artists, IUser creator)
 {
     return(new User[0]);
 }
Exemple #43
0
 public ViewSuggestionsQueryHandler(IMapper mapper, IDatabaseContext context)
 {
     _context = context;
     _mapper  = mapper;
 }
Exemple #44
0
        private static Dictionary <int, StatsQueries.LocalizedValue> GetSongsWithNamesAndArtists(IDatabaseContext ctx, int[] topSongIds)
        {
            var songs = ctx.OfType <Song>().Query()
                        .Where(a => topSongIds.Contains(a.Id))
                        .Select(a => new StatsQueries.LocalizedValue
            {
                Name = new TranslatedString
                {
                    DefaultLanguage = a.Names.SortNames.DefaultLanguage,
                    English         = a.Names.SortNames.English + " (" + a.ArtistString.English + ")",
                    Romaji          = a.Names.SortNames.Romaji + " (" + a.ArtistString.Romaji + ")",
                    Japanese        = a.Names.SortNames.Japanese + " (" + a.ArtistString.Japanese + ")",
                },
                EntryId = a.Id
            }).ToDictionary(s => s.EntryId);

            return(songs);
        }
Exemple #45
0
 public CustomerContactTypeRepository(IDatabaseContext context)
 {
     _context = context;
 }
 public AccountManagement(IDatabaseContext context, int personId)
     : base(context, personId)
 {
 }
 internal LenderHelper(IDatabaseContext DatabaseConext)
     : base(DatabaseConext)
 {
 }
 public FakeRestrictiveAccess(IDatabaseContext context, int personId)
     : base(context, personId)
 {
 }
Exemple #49
0
 public ReportService(IDatabaseContext databaseContext)
 {
     _db = databaseContext;
 }
Exemple #50
0
 public AutomatedController(IDatabaseContext context)
     : base(context)
 {
 }
 public MembershipService(IDatabaseContext databaseContext)
 {
     this.databaseContext = databaseContext;
 }
Exemple #52
0
 public HomeController(IDatabaseContext context, AppManager appManager)
 {
     this._context    = context;
     this._appManager = appManager;
 }
Exemple #53
0
 public TagFactoryRepository(IDatabaseContext <Tag> ctx, AgentLoginData loginData)
 {
     this.ctx       = ctx;
     this.loginData = loginData;
 }
 public IngredienteRepository(IDatabaseContext databaseContext)
 {
     _databaseContext = databaseContext;
 }
 protected HelperBase(IDatabaseContext DatabaseContext)
 {
     this._databaseContext = DatabaseContext;
 }
Exemple #56
0
 public Repository(IDatabaseContext <TContext> context)
 {
     _context      = context;
     _dbConnection = (_context as DbContext).Database.GetDbConnection();
     _dbSet        = _context.Set <TEntity>();
 }
 public SequenceTable(IDatabaseContext dbContext, TableInfo tableInfo)
     : base(dbContext)
 {
     this.tableInfo = tableInfo;
 }
 public HomeController(IDatabaseContext databaseContext)
 {
     _databaseContext = databaseContext;
 }
Exemple #59
0
 public BuildingsController(IDatabaseContext databaseContext)
 {
     _databaseContext = databaseContext;
 }
 public Task <IReadOnlyCollection <User> > SendNotificationsAsync(IDatabaseContext ctx, IEntryWithNames entry, IEnumerable <Artist> artists, IUser creator)
 {
     return(Task.FromResult((IReadOnlyCollection <User>) new List <User>()));
 }