コード例 #1
0
 public bool ContainsObject(ObjectName name)
 {
     return(cache.ContainsKey(name));
 }
コード例 #2
0
 protected override bool OnTearDown(string testName, IQuery query)
 {
     query.Access().DropObject(DbObjectType.Table, ObjectName.Parse("APP.test_table"));
     return(true);
 }
コード例 #3
0
        public static IDbObject GetObject(this ISession session, DbObjectType objectType, ObjectName objectName, AccessType accessType)
        {
            var obj = session.Transaction.GetObject(objectType, objectName);

            if (obj != null)
            {
                session.Access(obj, accessType);
            }

            return(obj);
        }
コード例 #4
0
 public void SetObject(ObjectName name, TCached obj)
 {
     ignoreCaseNames[name] = name;
     cache[name]           = obj;
 }
コード例 #5
0
 public static ConstraintInfo QueryTablePrimaryKey(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.QueryTablePrimaryKey(tableName));
 }
コード例 #6
0
 public static void CheckConstraintViolations(this ISession session, ObjectName tableName)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public static ObjectName ResolveTableName(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.ResolveTableName(tableName));
 }
コード例 #8
0
 public static ObjectName[] QueryTablesRelationallyLinkedTo(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.QueryTablesRelationallyLinkedTo(tableName));
 }
コード例 #9
0
 public static void DropObject(this ISession session, DbObjectType objectType, ObjectName objectName)
 {
     session.Transaction.DropObject(objectType, objectName);
 }
コード例 #10
0
 public static ObjectName ResolveObjectName(this ISession session, DbObjectType objectType, ObjectName objectName)
 {
     return(session.Transaction.ResolveObjectName(objectType, objectName));
 }
コード例 #11
0
 public static IDbObject FindObject(this ISession session, ObjectName objectName)
 {
     return(session.Transaction.FindObject(objectName));
 }
コード例 #12
0
        private static void CreateTestTable(string testName, IQuery context)
        {
            var tableName1 = ObjectName.Parse("APP.test_table");

            context.Access().CreateTable(table => table
                                         .Named(tableName1)
                                         .WithColumn(column => column
                                                     .Named("id")
                                                     .HavingType(PrimitiveTypes.Integer())
                                                     .WithDefault(SqlExpression.FunctionCall("UNIQUEKEY",
                                                                                             new SqlExpression[] { SqlExpression.Constant(tableName1.FullName) })))
                                         .WithColumn("first_name", PrimitiveTypes.String())
                                         .WithColumn("last_name", PrimitiveTypes.String())
                                         .WithColumn("birth_date", PrimitiveTypes.DateTime())
                                         .WithColumn("active", PrimitiveTypes.Boolean()));

            context.Session.Access().AddPrimaryKey(tableName1, "id", "PK_TEST_TABLE");

            if (testName.EndsWith("ConstraintCheck") ||
                testName.EndsWith("Violation"))
            {
                var tableName2 = ObjectName.Parse("APP.test_table2");
                context.Access().CreateTable(table => {
                    table
                    .Named(tableName2)
                    .WithColumn(column => column
                                .Named("id")
                                .HavingType(PrimitiveTypes.Integer())
                                .WithDefault(SqlExpression.FunctionCall("UNIQUEKEY",
                                                                        new SqlExpression[] { SqlExpression.Constant(tableName2.FullName) })));

                    if (testName.StartsWith("SetDefault"))
                    {
                        table.WithColumn(column => column
                                         .Named("person_id")
                                         .HavingType(PrimitiveTypes.Integer())
                                         .WithDefault(SqlExpression.Constant(0)));
                    }
                    else
                    {
                        table.WithColumn(column => column
                                         .Named("person_id")
                                         .HavingType(PrimitiveTypes.Integer())
                                         .NotNull(testName.EndsWith("Violation")));
                    }

                    table.WithColumn("dept_no", PrimitiveTypes.Integer());
                });

                context.Access().AddPrimaryKey(tableName2, "id", "PK_TEST_TABLE2");

                ForeignKeyAction?onUpdate = null;
                if (testName.StartsWith("SetNull"))
                {
                    onUpdate = ForeignKeyAction.SetNull;
                }
                else if (testName.StartsWith("SetDefault"))
                {
                    onUpdate = ForeignKeyAction.SetDefault;
                }
                else if (testName.StartsWith("Cascade"))
                {
                    onUpdate = ForeignKeyAction.Cascade;
                }

                if (onUpdate != null)
                {
                    context.Access()
                    .AddForeignKey(tableName2, new[] { "person_id" }, tableName1, new[] { "id" }, ForeignKeyAction.NoAction,
                                   onUpdate.Value, "FKEY_TEST_TABLE2");
                }
            }
        }
コード例 #13
0
 protected Field Select(ObjectName functionName, params SqlExpression[] args)
 {
     return(AdminQuery.SelectFunction(functionName, args));
 }
コード例 #14
0
 public static int DropTableConstraint(this ISession session, ObjectName tableName, string constraintName)
 {
     return(session.Transaction.DropTableConstraint(tableName, constraintName));
 }
コード例 #15
0
 public static ITable GetTable(this ISession session, ObjectName tableName)
 {
     tableName = session.ResolveTableName(tableName);
     return(session.GetObject(DbObjectType.Table, tableName) as ITable);
 }
コード例 #16
0
 public static bool DropTablePrimaryKey(this ISession session, ObjectName tableName, string constraintName)
 {
     return(session.Transaction.DropTablePrimaryKey(tableName, constraintName));
 }
コード例 #17
0
 public static TableInfo GetTableInfo(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.GetTableInfo(tableName));
 }
コード例 #18
0
 public static ConstraintInfo[] QueryTableCheckExpressions(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.QueryTableCheckExpressions(tableName));
 }
コード例 #19
0
 public static string GetTableType(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.GetTableType(tableName));
 }
コード例 #20
0
 public static ConstraintInfo[] QueryTableForeignKeys(this ISession session, ObjectName tableName)
 {
     return(session.Transaction.QueryTableForeignKeys(tableName));
 }
コード例 #21
0
 public static void AddForeignKey(this ISession session, ObjectName table, string[] columns,
                                  ObjectName refTable, string[] refColumns,
                                  ForeignKeyAction deleteRule, ForeignKeyAction updateRule, ConstraintDeferrability deferred, String constraintName)
 {
     session.Transaction.AddForeignKey(table, columns, refTable, refColumns, deleteRule, updateRule, deferred, constraintName);
 }
コード例 #22
0
 public static IDbObject GetObject(this ISession session, DbObjectType objectType, ObjectName objectName)
 {
     return(GetObject(session, objectType, objectName, AccessType.ReadWrite));
 }
コード例 #23
0
 public static void AddUniqueKey(this ISession session, ObjectName tableName, string[] columns, ConstraintDeferrability deferrability, string constraintName)
 {
     session.Transaction.AddUniqueKey(tableName, columns, deferrability, constraintName);
 }
コード例 #24
0
 public static bool ObjectExists(this ISession session, ObjectName objectName)
 {
     return(session.Transaction.ObjectExists(objectName));
 }
コード例 #25
0
 public static void AddCheck(this ISession session, ObjectName tableName, SqlExpression expression, ConstraintDeferrability deferrability,
                             string constraintName)
 {
     session.Transaction.AddCheck(tableName, expression, deferrability, constraintName);
 }
コード例 #26
0
 public bool TryGetObject(ObjectName name, out TCached obj)
 {
     return(cache.TryGetValue(name, out obj));
 }
コード例 #27
0
 public static void DropAllTableConstraints(this ISession session, ObjectName tableName)
 {
     session.Transaction.DropAllTableConstraints(tableName);
 }
コード例 #28
0
 public bool RemoveObject(ObjectName name)
 {
     return(ignoreCaseNames.Remove(name) && cache.Remove(name));
 }
コード例 #29
0
        protected override bool OnSetUp(string testName, IQuery query)
        {
            triggerName = ObjectName.Parse("APP.trigger1");
            query.Access().CreateTrigger(new ProcedureTriggerInfo(triggerName, ObjectName.Parse("APP.table1"),
                                                                  TriggerEventTime.After, TriggerEventType.Delete, ObjectName.Parse("APP.proc1")));

            return(true);
        }