Beispiel #1
0
        private string BuildSqlCmdTextForLoadDestinationKeySets(
            IEnumerable <KeySet> immutableKeySets,
            TableMapping tableMapping,
            IEnumerable <string> keyColumnNames)
        {
            var immutableKeyColumnName = tableMapping.GetImmutableKeyColumnName();

            StringBuilder sb = new StringBuilder();

            sb.Append("SELECT ");
            foreach (var keyColumnName in keyColumnNames)
            {
                sb.AppendFormat(" {0}, ", keyColumnName);
            }

            sb.Remove(sb.Length - 2, 2);

            sb.AppendFormat(" FROM {0} ", tableMapping.Destination);

            sb.AppendFormat(
                " WHERE {0} in ({1})",
                immutableKeyColumnName,
                string.Join(
                    ",",
                    immutableKeySets.Select(
                        keySet => BuildSqlStringForValue(keySet.Keys.First().Item3, keySet.Keys.First().Item2)).ToArray()));

            return(sb.ToString());
        }
Beispiel #2
0
        private HashSet <KeySet> GetImmutableKeySets(
            Dictionary <KeySet, Dictionary <string, object> > sourceDataValues,
            TableMapping tableMapping,
            Dictionary <string, DbColumnType> destColumnNameTypeMappings)
        {
            var immutableKeySets       = new HashSet <KeySet>();
            var immutableKeyColumnName = tableMapping.GetImmutableKeyColumnName();

            foreach (var row in sourceDataValues.Values)
            {
                KeySet keySet = new KeySet();
                keySet.Add(immutableKeyColumnName, destColumnNameTypeMappings[immutableKeyColumnName], row[immutableKeyColumnName]);

                if (!immutableKeySets.Contains(keySet))
                {
                    immutableKeySets.Add(keySet);
                }
            }

            return(immutableKeySets);
        }