Exemple #1
0
        /// <summary>
        /// Checks if the values of this <see cref="ColumnSchema"/> are equal to the values in the
        /// <paramref name="other"/>.
        /// </summary>
        /// <param name="other">The other <see cref="ColumnSchema"/>.</param>
        /// <returns>True if all values are equal; otherwise false.</returns>
        public bool EqualValues(ColumnSchema other)
        {
            foreach (var kvp in _values)
            {
                var otherValue = other[kvp.Key];

                var v1 = string.IsNullOrEmpty(otherValue) ? null : otherValue;
                var v2 = string.IsNullOrEmpty(kvp.Value) ? null : kvp.Value;

                if (v1 != v2)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Checks if the values of this <see cref="ColumnSchema"/> are equal to the values in the
        /// <paramref name="other"/>.
        /// </summary>
        /// <param name="other">The other <see cref="ColumnSchema"/>.</param>
        /// <returns>True if all values are equal; otherwise false.</returns>
        public bool EqualValues(ColumnSchema other)
        {
            foreach (var kvp in _values)
            {
                var otherValue = other[kvp.Key];

                var v1 = string.IsNullOrEmpty(otherValue) ? null : otherValue;
                var v2 = string.IsNullOrEmpty(kvp.Value) ? null : kvp.Value;

                if (v1 != v2)
                    return false;
            }

            return true;
        }
Exemple #3
0
        static IEnumerable<TableSchema> ExecuteQuery(MySqlConnection conn, DbConnectionSettings dbSettings)
        {
            var tableColumns = new Dictionary<string, List<ColumnSchema>>();

            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = GetQueryString(dbSettings);
                using (var r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        var column = new ColumnSchema(r);

                        List<ColumnSchema> columnList;
                        if (!tableColumns.TryGetValue(column.TableName, out columnList))
                        {
                            columnList = new List<ColumnSchema>();
                            tableColumns.Add(column.TableName, columnList);
                        }

                        columnList.Add(column);
                    }
                }
            }

            var ret = tableColumns.Select(x => new TableSchema(x.Key, x.Value));

            // ToArray() required to serialize, otherwise it is a LINQ statement
            return ret.ToArray();
        }