Inheritance: NamedConfigurationElement
コード例 #1
0
        private void LoadColumn(ColumnElement columnElement, Table table)
        {
            if (columnElement == null)
                return;

            Columns.Add(new Tuple<string, string, DbType, int>(table.GetNameWithSchema(), columnElement.Name,DbTypeConverter.FromDataType(columnElement.DataType), columnElement.Length));
            if(columnElement.IsPrimaryKey)
            {
                PrimaryKeys.Add(new Tuple<string, string>(table.GetNameWithSchema(), columnElement.Name));
            }

            if(!string.IsNullOrWhiteSpace(columnElement.ForeignKey))
            {
                var parts = columnElement.ForeignKey.Split('.');
                var schemaName = parts.Length > 2 ? parts[0] : null;
                var objectName = parts.Length > 2 ? parts[1] : parts[0];
                var columnName = parts.Length > 2 ? parts[2] : parts[1];
                ForeignKeys.Add(new ForeignKey(new ObjectName(table.Schema, table.ActualName), new[] { columnElement.Name }, new ObjectName(schemaName, objectName), new[] { columnName }));
            }
        }
コード例 #2
0
        private void LoadColumn(ColumnElement columnElement, Table table)
        {
            if (columnElement == null)
            {
                return;
            }

            Columns.Add(new Tuple <string, string, DbType, int>(table.GetNameWithSchema(), columnElement.Name, DbTypeConverter.FromDataType(columnElement.DataType), columnElement.Length));
            if (columnElement.IsPrimaryKey)
            {
                PrimaryKeys.Add(new Tuple <string, string>(table.GetNameWithSchema(), columnElement.Name));
            }

            if (!string.IsNullOrWhiteSpace(columnElement.ForeignKey))
            {
                var parts      = columnElement.ForeignKey.Split('.');
                var schemaName = parts.Length > 2 ? parts[0] : null;
                var objectName = parts.Length > 2 ? parts[1] : parts[0];
                var columnName = parts.Length > 2 ? parts[2] : parts[1];
                ForeignKeys.Add(new ForeignKey(new ObjectName(table.Schema, table.ActualName), new[] { columnElement.Name }, new ObjectName(schemaName, objectName), new[] { columnName }));
            }
        }