示例#1
0
        private void LoadForeignKeys()
        {
            // Get foreign keys for table in context.
            var tableForeignKeys = Database.ForeignKeys.AsEnumerable()
                                   .Where(
                foreignKey => foreignKey.Field <string>("table_name") == SqlName &&
                foreignKey.Field <string>("table_schema_name") == Schema
                ).ToList();

            // If none, return.
            if (tableForeignKeys.Any() == false)
            {
                return;
            }

            // Create foreign keys.
            foreach (var tableForeignKey in tableForeignKeys)
            {
                string     foreign_key_name = tableForeignKey["foreign_key_name"].ToString();
                ForeignKey foreignKey       = new ForeignKey(tableForeignKey, this);
                ForeignKeys.GetOrAdd(foreign_key_name, foreignKey);
            }
        }