public StatContext stat() { StatContext _localctx = new StatContext(_ctx, State); EnterRule(_localctx, 2, RULE_stat); try { State = 20; switch (Interpreter.AdaptivePredict(_input, 1, _ctx)) { case 1: _localctx = new PrintExprContext(_localctx); EnterOuterAlt(_localctx, 1); { State = 11; expr(0); State = 12; Match(NEWLINE); } break; case 2: _localctx = new AssignContext(_localctx); EnterOuterAlt(_localctx, 2); { State = 14; Match(ID); State = 15; Match(3); State = 16; expr(0); State = 17; Match(NEWLINE); } break; case 3: _localctx = new BlankContext(_localctx); EnterOuterAlt(_localctx, 3); { State = 19; Match(NEWLINE); } break; } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public static void EnsureTenantInitialized(string schema) { using (var db = new ListContext(schema)) { // Ensure that the physical database exists (create an empty one if not) using (var b = new BlankContext(db.Database.Connection)) { if (!b.Database.Exists()) { ((IObjectContextAdapter)b).ObjectContext.CreateDatabase(); } } // Ensure the schema exists (migrations won't create it since we are messing with object names) db.Database.ExecuteSqlCommand(string.Format(_schemaCreationSql, schema)); // Apply migrations redirected to the schema var config = new Configuration(); config.SetSqlGenerator(SqlProviderServices.ProviderInvariantName, new SchemaRenamingMigrationSqlGenerator(schema)); config.SetHistoryContextFactory(SqlProviderServices.ProviderInvariantName, (c, s) => new HistoryContext(c, schema)); new DbMigrator(config).Update(); } }