コード例 #1
0
        public string?WhereSignature()
        {
            var includeColumns = IncludeColumns.HasItems() ? IncludeColumns.ToString(c => c.Name, "_") : null;

            if (string.IsNullOrEmpty(Where) && includeColumns == null)
            {
                return(null);
            }

            return("__" + StringHashEncoder.Codify(Where + includeColumns));
        }
コード例 #2
0
        protected override string ColumnSignature()
        {
            string columns = base.ColumnSignature();

            if (string.IsNullOrEmpty(Where))
            {
                return(columns);
            }

            return(columns + "__" + StringHashEncoder.Codify(Where));
        }
コード例 #3
0
ファイル: UniqueIndex.cs プロジェクト: crazyants/framework-2
        protected string ColumnSignature()
        {
            string columns = Columns.ToString(c => c.Name, "_");

            if (string.IsNullOrEmpty(Where))
            {
                return(columns);
            }

            return(columns + "__" + StringHashEncoder.Codify(Where));
        }
コード例 #4
0
        protected string ColumnSignature()
        {
            string columns        = Columns.ToString(c => c.Name, "_");
            var    includeColumns = IncludeColumns.HasItems() ? IncludeColumns.ToString(c => c.Name, "_") : null;

            if (string.IsNullOrEmpty(Where) && includeColumns == null)
            {
                return(columns);
            }

            return(columns + "__" + StringHashEncoder.Codify(Where + includeColumns));
        }
コード例 #5
0
        public static string GetKey(ScriptRequest request)
        {
            return(Elements.GetOrAdd(request, r =>
            {
                var elem = new ScriptElement
                {
                    Request = r,
                    Content = null,
                    Key = StringHashEncoder.Codify(request.ToString())
                };

                return ElementsByKey.GetOrAdd(elem.Key, elem);
            }
                                     ).Key);
        }
コード例 #6
0
        private static Dictionary <string, DiffIndex> ApplyIndexAutoReplacements(DiffTable diff, ITable tab, Dictionary <string, Index> dictionary)
        {
            List <string> oldOnly = diff.Indices.Keys.Where(n => !dictionary.ContainsKey(n)).ToList();
            List <string> newOnly = dictionary.Keys.Where(n => !diff.Indices.ContainsKey(n)).ToList();

            if (oldOnly.Count == 0 || newOnly.Count == 0)
            {
                return(diff.Indices);
            }

            Dictionary <string, string> replacements = new Dictionary <string, string>();

            foreach (var o in oldOnly)
            {
                var oldIx = diff.Indices[o];

                var nIx = newOnly.FirstOrDefault(n =>
                {
                    var newIx = dictionary[n];
                    if (oldIx.IsPrimary && newIx is PrimaryClusteredIndex)
                    {
                        return(true);
                    }

                    if (oldIx.IsPrimary || newIx is PrimaryClusteredIndex)
                    {
                        return(false);
                    }

                    if (oldIx.IsUnique != (newIx is UniqueIndex))
                    {
                        return(false);
                    }

                    if (oldIx.ViewName != null || (newIx is UniqueIndex) && ((UniqueIndex)newIx).ViewName != null)
                    {
                        return(false);
                    }

                    var news = newIx.Columns.Select(c => diff.Columns.TryGetC(c.Name)?.Name).NotNull().ToHashSet();

                    if (!news.SetEquals(oldIx.Columns))
                    {
                        return(false);
                    }

                    var uix = newIx as UniqueIndex;
                    if (uix != null && uix.Where != null && !oldIx.IndexName.EndsWith(StringHashEncoder.Codify(uix.Where)))
                    {
                        return(false);
                    }

                    return(true);
                });

                if (nIx != null)
                {
                    replacements.Add(o, nIx);
                    newOnly.Remove(nIx);
                }
            }

            if (replacements.IsEmpty())
            {
                return(diff.Indices);
            }

            return(diff.Indices.SelectDictionary(on => replacements.TryGetC(on) ?? on, dif => dif));
        }