static string TryToStringElement(object value, Type type, out string result) { FilterType filterType = QueryUtils.GetFilterType(type); var list = SpecificFilters.TryGetC(filterType); if (list != null) { foreach (var fvc in list) { string error = fvc.TryToStringValue(value, type, out result); if (error != Continue) { return(error); } } } if (value == null) { result = null; } else if (value is IFormattable) { result = ((IFormattable)value).ToString(null, CultureInfo.InvariantCulture); } else { result = value.ToString(); } return(null); }
static Result <string?> TryToStringElement(object?value, Type type) { FilterType filterType = QueryUtils.GetFilterType(type); var converters = SpecificConverters.TryGetC(filterType); if (converters != null) { foreach (var fvc in converters) { var r = fvc.TryToStringValue(value, type); if (r != null) { return(r); } } } string?result = value == null ? null : value is IFormattable f?f.ToString(null, CultureInfo.InvariantCulture) : value.ToString(); return(new Result <string?> .Success(result)); }
public void RegisterGetButtonBarElement <T>(Func <T, EntityButtonContext, FrameworkElement> action) where T : ModifiableEntity { Func <ModifiableEntity, EntityButtonContext, FrameworkElement> casted = (obj, args) => action((T)obj, args); var prev = GetButtonBarElementByType.TryGetC(typeof(T)); GetButtonBarElementByType[typeof(T)] = prev + casted; }
public bool RemoveEdge(T from, T to) { var dic = adjacency.TryGetC(from); if (dic == null) { return(false); } return(dic.Remove(to)); }
public bool RemoveEdge(T from, T to) { var hashSet = adjacency.TryGetC(from); if (hashSet == null) { return(false); } return(hashSet.Remove(to)); }
public static IEnumerable <TypeConditionSymbol> ConditionsFor(Type type) { var dic = infos.TryGetC(type); if (dic == null) { return(Enumerable.Empty <TypeConditionSymbol>()); } return(dic.Keys); }
protected internal override Expression VisitAggregateRequest(AggregateRequestsExpression request) { var ag = (AggregateExpression)this.Visit(request.Aggregate); var newAlias = aliasMap.TryGetC(request.GroupByAlias) ?? request.GroupByAlias; if (ag != request.Aggregate || request.GroupByAlias != newAlias) { return(new AggregateRequestsExpression(newAlias, ag)); } return(request); }
public static char?GetGender(string name, CultureInfo?culture = null) { var defCulture = culture ?? CultureInfo.CurrentUICulture; var detector = GenderDetectors.TryGetC(defCulture.TwoLetterISOLanguageName); if (detector == null) { return(null); } return(detector.GetGender(name)); }
public static Dictionary <OperationSymbol, string> GetContextualCanExecute(IEnumerable <Lite <IEntity> > lites, List <OperationSymbol> operationSymbols) { Dictionary <OperationSymbol, string> result = null; using (ExecutionMode.Global()) { foreach (var grLites in lites.GroupBy(a => a.EntityType)) { var operations = operationSymbols.Select(opKey => FindOperation(grLites.Key, opKey)).ToList(); foreach (var grOperations in operations.GroupBy(a => a.GetType().GetGenericArguments().Let(arr => Tuple.Create(arr[0], arr[1])))) { var dic = giGetContextualGraphCanExecute.GetInvoker(grLites.Key, grOperations.Key.Item1, grOperations.Key.Item2)(grLites, grOperations); if (result == null) { result = dic; } else { foreach (var kvp in dic) { result[kvp.Key] = "\r\n".Combine(result.TryGetC(kvp.Key), kvp.Value); } } } } } return(result); }
public static void SynchronizeProgressForeach <K, N, O>( Dictionary <K, N> newDictionary, Dictionary <K, O> oldDictionary, Action <K, N> createNew, Action <K, O> removeOld, Action <K, N, O> merge) where O : class where N : class { HashSet <K> keys = new HashSet <K>(); keys.UnionWith(oldDictionary.Keys); keys.UnionWith(newDictionary.Keys); keys.ProgressForeach(key => key.ToString(), key => { var oldVal = oldDictionary.TryGetC(key); var newVal = newDictionary.TryGetC(key); if (oldVal == null) { createNew?.Invoke(key, newVal); } else if (newVal == null) { removeOld?.Invoke(key, oldVal); } else { merge?.Invoke(key, newVal, oldVal); } }); }
private static SqlPreCommandSimple UpdateByFkChange(string tn, DiffColumn difCol, IColumn tabCol, Func <ObjectName, ObjectName> changeName, Dictionary <ObjectName, ObjectName> copyDataFrom) { if (difCol.ForeignKey == null || tabCol.ReferenceTable == null || tabCol.AvoidForeignKey) { return(null); } ObjectName oldFk = changeName(difCol.ForeignKey.TargetTable); if (oldFk.Equals(tabCol.ReferenceTable.Name)) { return(null); } var newComesFrom = copyDataFrom.TryGetC(tabCol.ReferenceTable.Name); if (newComesFrom != null && oldFk.Equals(newComesFrom)) { return(null); } AliasGenerator ag = new AliasGenerator(); return(new SqlPreCommandSimple( @"UPDATE {2} SET {0} = -- get {5} id from {4}.Id FROM {1} {2} JOIN {3} {4} ON {2}.{0} = {4}.Id".FormatWith(tabCol.Name, tn, ag.NextTableAlias(tn), oldFk, ag.NextTableAlias(oldFk.Name), tabCol.ReferenceTable.Name.Name))); }
protected void DistributeErrors(Dictionary <Guid, IntegrityCheck> errorDictionary) { var mod = this.UntypedValue as ModifiableEntity; var integrityCheck = mod == null ? null : errorDictionary.TryGetC(mod.temporalId); foreach (var child in this.Children()) { var pv = child.PropertyValidator; if (pv != null && integrityCheck != null) { string error = integrityCheck.Errors.TryGetC(pv.PropertyInfo.Name); if (error != null) { integrityCheck.Errors.Remove(pv.PropertyInfo.Name); child.Error.AddRange(error.SplitNoEmpty("\r\n")); } } child.DistributeErrors(errorDictionary); } if (integrityCheck != null && integrityCheck.Errors.IsEmpty()) { errorDictionary.Remove(mod.temporalId); } }
/// <summary> /// Similar methods of inheritors will be automatically called by Signum.MSBuildTask using AutoInitiAttribute /// </summary> public Symbol(Type declaringType, string fieldName) { this.fieldInfo = declaringType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (this.fieldInfo == null) throw new InvalidOperationException(string.Format("No field with name {0} found in {1}", fieldName, declaringType.Name)); this.Key = declaringType.Name + "." + fieldName; try { Symbols.GetOrCreate(this.GetType()).Add(this.Key, this); } catch (Exception e) when (StartParameters.IgnoredCodeErrors != null) { //Could happend if Dynamic code has a duplicated name this.fieldInfo = null; this.Key = null; StartParameters.IgnoredCodeErrors.Add(e); return; } var dic = Ids.TryGetC(this.GetType()); if (dic != null) { PrimaryKey? id = dic.TryGetS(this.Key); if (id != null) this.SetId(id.Value); } }
public void Configure(FilterInfo filterInfo, ControllerContext controllerContext, ActionDescriptor actionDescription) { if (removeFilters != null) { foreach (var type in removeFilters) { filterInfo.RemoveFilters(type); } } if (addFilters != null) { filterInfo.AddFilters(addFilters); } if (addFilterDelegate != null) { var ctx = new ConditionalFilterContext(controllerContext, actionDescription, filterInfo); filterInfo.AddFilters( addFilterDelegate.GetInvocationListTyped() .Select(del => del(ctx)).NotNull()); } var afc = actions?.TryGetC(actionDescription.ActionName); if (afc != null) { afc.Configure(filterInfo, controllerContext, actionDescription); } }
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.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)); }
/// <summary> /// /// </summary> /// <param name="frame">Inheritors should use new StackFrame(1, false) and add [MethodImpl(MethodImplOptions.NoInlining)]</param> /// <param name="fieldName">Inheritors should use [CallerMemberName]</param> protected void MakeSymbol(StackFrame frame, string fieldName) { var mi = frame.GetMethod(); if (mi != mi.DeclaringType.TypeInitializer) { throw new InvalidOperationException(string.Format("{0} {1} can only be created in static field initializers", GetType().Name, fieldName)); } if (!IsStaticClass(mi.DeclaringType)) { throw new InvalidOperationException(string.Format("{0} {1} is declared in {2}, but {2} is not static", GetType().Name, fieldName, mi.DeclaringType.Name)); } this.fieldInfo = mi.DeclaringType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (this.fieldInfo == null) { throw new InvalidOperationException(string.Format("No field with name {0} found in {1}", fieldName, mi.DeclaringType.Name)); } this.Key = mi.DeclaringType.Name + "." + fieldName; var dic = Ids.TryGetC(this.GetType()); if (dic != null) { var tup = dic.TryGetC(this.Key); if (tup != null) { this.SetIdAndName(tup); } } Symbols.GetOrCreate(this.GetType()).Add(this.Key, this); }
static string GetMemberNiceName(MemberInfo memberInfo) { //var cc = CultureInfo.CurrentUICulture; var type = memberInfo.DeclaringType; if (!LocalizedAssembly.HasDefaultAssemblyCulture(type.Assembly)) { var f = ExternalEnums.TryGetC(type); if (f != null) { return(f(memberInfo)); } return(memberInfo.GetCustomAttribute <DescriptionAttribute>()?.Description ?? memberInfo.Name.NiceName()); } var result = Fallback(type, lt => lt.Members.TryGetC(memberInfo.Name), lt => OnNotLocalizedMemeber(null, memberInfo)); if (result != null) { return(result); } return(result); }
void PrintOptions(int skip, int take) { var keys = dictionary.Keys.ToList(); var max = Math.Min(keys.Count, skip + take); for (int i = skip; i < max; i++) { var key = keys[i]; string?value = separators.TryGetC(i); if (value.HasText()) { Console.WriteLine(); Console.WriteLine(value); } SafeConsole.WriteColor(ConsoleColor.White, " " + keys[i]); Console.WriteLine(" - " + dictionary[key].Description); } if (skip + take >= dictionary.Count) { return; } SafeConsole.WriteColor(ConsoleColor.White, " +"); Console.WriteLine(" - " + ConsoleMessage.More.NiceToString()); }
public static T?SelectInteractive <T>(string str, Dictionary <string, T> dictionary, string context) where T : class { T?result = dictionary.TryGetC(str); if (result != null) { return(result); } StringDistance sd = new StringDistance(); var list = dictionary.Keys.Select(s => new { s, lcs = sd.LongestCommonSubsequence(str, s) }).OrderByDescending(s => s.lcs !).Select(a => a.s !).ToList(); var cs = new ConsoleSwitch <int, string>("{0} has been renamed in {1}".FormatWith(str, context)); cs.Load(list); string?selected = cs.Choose(); if (selected == null) { return(null); } return(dictionary.GetOrThrow(selected)); }
private static PropertyRoute GetCurrentPropertyRoute(object value) { var pr = JsonSerializerExtensions.CurrentPropertyRoute; if (value is IRootEntity) { pr = PropertyRoute.Root(value.GetType()); } if (pr == null) { var embedded = (EmbeddedEntity)value; var hpr = DefaultPropertyRoutes.TryGetC(embedded.GetType()); if (hpr == null) { throw new InvalidOperationException($"Impossible to determine PropertyRoute for {value.GetType().Name}. Consider adding a new value to {nameof(EntityJsonConverter)}.{nameof(EntityJsonConverter.DefaultPropertyRoutes)}."); } pr = hpr; } else if (pr.Type.ElementType() == value.GetType()) { pr = pr.Add("Item"); //We habe a custom MListConverter but not for other simple collections } return(pr); }
public static SqlPreCommand?SynchronizeScript <K, N, O>( Spacing spacing, Dictionary <K, N> newDictionary, Dictionary <K, O> oldDictionary, Func <K, N, SqlPreCommand?>?createNew, Func <K, O, SqlPreCommand?>?removeOld, Func <K, N, O, SqlPreCommand?>?mergeBoth) where O : class where N : class where K : notnull { HashSet <K> set = new HashSet <K>(); set.UnionWith(newDictionary.Keys); set.UnionWith(oldDictionary.Keys); return(set.Select(key => { var newVal = newDictionary.TryGetC(key); var oldVal = oldDictionary.TryGetC(key); if (newVal == null) { return removeOld == null ? null : removeOld(key, oldVal !); } if (oldVal == null) { return createNew == null ? null : createNew(key, newVal); } return mergeBoth == null ? null : mergeBoth(key, newVal, oldVal); }).Combine(spacing)); }
public static char?GetGender(string name, CultureInfo culture = null) { if (culture == null) { culture = CultureInfo.CurrentUICulture; } IGenderDetector detector = GenderDetectors.TryGetC(culture.TwoLetterISOLanguageName); if (detector == null) { return(null); } return(detector.GetGender(name)); }
public XElement ExportXml() { return(new XElement("Type", new XAttribute("Name", Type.Name), !Options.IsSetAssert(DescriptionOptions.Description, Type) || Description == null || (Assembly.IsDefault && Description == DescriptionManager.DefaultTypeDescription(Type)) ? null : new XAttribute("Description", Description), !Options.IsSetAssert(DescriptionOptions.PluralDescription, Type) || PluralDescription == null || (PluralDescription == NaturalLanguageTools.Pluralize(Description, Assembly.Culture)) ? null : new XAttribute("PluralDescription", PluralDescription), !Options.IsSetAssert(DescriptionOptions.Gender, Type) || Gender == null || (Gender == NaturalLanguageTools.GetGender(Description, Assembly.Culture)) ? null : new XAttribute("Gender", Gender.ToString()), !Options.IsSetAssert(DescriptionOptions.Members, Type) ? null : (from m in GetMembers(Type) where DescriptionManager.OnShouldLocalizeMember(m) orderby m.Name let value = Members.TryGetC(m.Name) where value != null && !(Assembly.IsDefault && (DescriptionManager.DefaultMemberDescription(m) == value)) select new XElement("Member", new XAttribute("Name", m.Name), new XAttribute("Description", value))) )); }
static Expression EntityIn(Expression newItem, Dictionary <Type, PrimaryKey[]> entityIDs) { EntityExpression ee = newItem as EntityExpression; if (ee != null) { return(InPrimaryKey(ee.ExternalId, entityIDs.TryGetC(ee.Type) ?? new PrimaryKey[0])); } ImplementedByExpression ib = newItem as ImplementedByExpression; if (ib != null) { return(ib.Implementations.JoinDictionary(entityIDs, (t, f, values) => Expression.And(DbExpressionNominator.FullNominate(NotEqualToNull(f.ExternalId)), InPrimaryKey(f.ExternalId, values))) .Values.AggregateOr()); } ImplementedByAllExpression iba = newItem as ImplementedByAllExpression; if (iba != null) { return(entityIDs.Select(kvp => Expression.And( EqualNullable(new PrimaryKeyExpression(QueryBinder.TypeConstant(kvp.Key).Nullify()), iba.TypeId.TypeColumn), InPrimaryKey(iba.Id, kvp.Value))).AggregateOr()); } throw new InvalidOperationException("EntityIn not defined for newItem of type {0}".FormatWith(newItem.Type.Name)); }
private IEnumerable <XElement> GetConnections(Lite <IWorkflowNodeEntity> lite) { List <XElement> result = new List <XElement>(); result.AddRange(incoming.TryGetC(lite).EmptyIfNull().Select(c => new XElement(bpmn + "incoming", c.bpmnElementId))); result.AddRange(outgoing.TryGetC(lite).EmptyIfNull().Select(c => new XElement(bpmn + "outgoing", c.bpmnElementId))); return(result); }
static IEnumerable <MenuItem> SearchControl_GetContextMenuItems(SearchControl sc) { if (!Navigator.IsViewable(typeof(PackageOperationEntity))) { return(Enumerable.Empty <MenuItem>()); } if (sc.SelectedItems.IsNullOrEmpty() || sc.SelectedItems.Count == 1) { return(null); } if (sc.Implementations.IsByAll) { return(null); } var type = sc.SelectedItems.Select(a => a.EntityType).Distinct().Only(); if (type == null) { return(null); } var result = (from oi in OperationClient.Manager.OperationInfos(type) where oi.IsEntityOperation let os = OperationClient.Manager.GetSettings <EntityOperationSettingsBase>(type, oi.OperationSymbol) let coc = newContextualOperationContext.GetInvoker(os?.OverridenType ?? type)(sc, oi, os?.ContextualFromManyUntyped) where os == null ? oi.Lite == true && oi.OperationType != OperationType.ConstructorFrom : !os.ContextualFromManyUntyped.HasIsVisible ? (oi.Lite == true && !os.HasIsVisible && oi.OperationType != OperationType.ConstructorFrom && (!os.HasClick || os.ContextualFromManyUntyped.HasClick)) : os.ContextualFromManyUntyped.OnIsVisible(coc) select coc).ToList(); if (result.IsEmpty()) { return(null); } var cleanKeys = result .Where(cod => cod.CanExecute == null && cod.OperationInfo.HasStates == true) .Select(cod => cod.OperationInfo.OperationSymbol).ToList(); if (cleanKeys.Any()) { Dictionary <OperationSymbol, string> canExecutes = Server.Return((IOperationServer os) => os.GetContextualCanExecute(sc.SelectedItems, cleanKeys)); foreach (var cod in result) { var ce = canExecutes.TryGetC(cod.OperationInfo.OperationSymbol); if (ce.HasText()) { cod.CanExecute = ce; } } } return(result.Select(coc => PackageOperationMenuItemConsturctor.Construct(coc))); }
protected internal override Expression VisitSelect(SelectExpression select) { Expression top = this.Visit(select.Top); SourceExpression from = this.VisitSource(select.From !); Expression where = this.Visit(select.Where); ReadOnlyCollection <ColumnDeclaration> columns = Visit(select.Columns, VisitColumnDeclaration); ReadOnlyCollection <OrderExpression> orderBy = Visit(select.OrderBy, VisitOrderBy); ReadOnlyCollection <Expression> groupBy = Visit(select.GroupBy, Visit); Alias newAlias = aliasMap.TryGetC(select.Alias) ?? select.Alias; if (top != select.Top || from != select.From || where != select.Where || columns != select.Columns || orderBy != select.OrderBy || groupBy != select.GroupBy || newAlias != select.Alias) { return(new SelectExpression(newAlias, select.IsDistinct, top, columns, from, where, orderBy, groupBy, select.SelectOptions)); } return(select); }
private static bool IsCreatedOrModified(Dictionary <string, object> dictionary, Entity ident) { var modified = (List <Entity>?)dictionary.TryGetC(ModifiedKey); if (modified != null && modified.Contains(ident)) { return(true); } var created = (List <Entity>?)dictionary.TryGetC(CreatedKey); if (created != null && created.Contains(ident)) { return(true); } return(false); }
public static string Replace(string connectionString) { if (replacements == null) { replacements = LoadReplacements(); } Match m = Regex.Match(connectionString, @"(Initial Catalog|Database)\s*=\s*(?<databaseName>[^;]*)\s*;?", RegexOptions.IgnoreCase); if (!m.Success) { throw new InvalidOperationException("Database name not found"); } string databaseName = m.Groups["databaseName"].Value; return(replacements.TryGetC(databaseName) ?? connectionString); }
List <Tab> IViewOverrides.ExpandTabs(List <Tab> tabs, string containerId, HtmlHelper helper, TypeContext context) { if (hiddenTabs != null && hiddenTabs.Contains(containerId)) { return(null); } List <Tab> newTabs = new List <Tab>(); var before = BeforeTabDictionary?.TryGetC(containerId); if (before != null) { foreach (var b in before.GetInvocationListTyped()) { var newTab = b(helper, context); if (newTab != null) { ExpandTab(newTab, helper, context, newTabs); } } } foreach (var item in tabs) { ExpandTab(item, helper, context, newTabs); } var after = AfterTabDictionary?.TryGetC(containerId); if (after != null) { foreach (var a in after.GetInvocationListTyped()) { var newTab = a(helper, context); if (newTab != null) { ExpandTab(newTab, helper, context, newTabs); } } } return(newTabs); }
static Expression EntityIn(Expression newItem, Dictionary<Type, PrimaryKey[]> entityIDs) { EntityExpression ee = newItem as EntityExpression; if (ee != null) return InPrimaryKey(ee.ExternalId, entityIDs.TryGetC(ee.Type) ?? new PrimaryKey[0]); ImplementedByExpression ib = newItem as ImplementedByExpression; if (ib != null) return ib.Implementations.JoinDictionary(entityIDs, (t, f, values) => Expression.And(DbExpressionNominator.FullNominate(NotEqualToNull(f.ExternalId)), InPrimaryKey(f.ExternalId, values))) .Values.AggregateOr(); ImplementedByAllExpression iba = newItem as ImplementedByAllExpression; if (iba != null) return entityIDs.Select(kvp => Expression.And( EqualNullable(new PrimaryKeyExpression(QueryBinder.TypeConstant(kvp.Key).Nullify()), iba.TypeId.TypeColumn), InPrimaryKey(iba.Id, kvp.Value))).AggregateOr(); throw new InvalidOperationException("EntityIn not defined for newItem of type {0}".FormatWith(newItem.Type.Name)); }
public static SqlPreCommand ReCreateFreeIndex(ITable table, DiffIndex index, string oldTable, Dictionary<string, string> tableReplacements) { if (index.IsControlledIndex) throw new InvalidOperationException("The Index is not a free index"); var onlyColumn = index.Columns.Only(); string indexName = onlyColumn != null && index.IndexName.StartsWith("FIX_") ? "FIX_{0}_{1}".Formato(table.Name.Name, (tableReplacements.TryGetC(onlyColumn) ?? onlyColumn)) : tableReplacements == null ? index.IndexName.Replace(oldTable, table.Name.Name) : index.IndexName.Replace(tableReplacements).Replace(oldTable, table.Name.Name); string columns = index.Columns.ToString(c => (tableReplacements.TryGetC(c) ?? c).SqlEscape(), ", "); return new SqlPreCommandSimple("CREATE INDEX {0} ON {1}({2})".Formato( indexName.SqlEscape(), table.Name, columns)); }
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); }