@@ -545,34 +545,38 @@ public void SaveFilter()
545545
546546 //EntityProfile.EnglishLabelField = TextBoxEnglishLabelField.Text;
547547
548- EntityProfile . Attributes = rowListAttrSource . Where ( field => field . IsSelected ) . Select ( field => field . Name ) . ToArray ( ) ;
548+ EntityProfile . Attributes = rowListAttrSource . Where ( field => field . IsSelected ) . Select ( field => field . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
549549 EntityProfile . AttributeRenames = rowListAttrSource . Where ( field => ! string . IsNullOrWhiteSpace ( field . Rename ) )
550550 . ToDictionary ( field => field . Name , field => field . Rename ) ;
551551 EntityProfile . AttributeLanguages = rowListAttrSource . Where ( field => ! string . IsNullOrWhiteSpace ( field . Language ) )
552552 . ToDictionary ( field => field . Name , field => field . Language ) ;
553553 EntityProfile . AttributeAnnotations = rowListAttrSource . Where ( field => ! string . IsNullOrWhiteSpace ( field . Annotations ) )
554554 . ToDictionary ( field => field . Name , field => field . Annotations ) ;
555- EntityProfile . ReadOnly = rowListAttrSource . Where ( field => field . IsReadOnly ) . Select ( field => field . Name ) . ToArray ( ) ;
556- EntityProfile . ClearFlag = rowListAttrSource . Where ( field => field . IsClearFlag ) . Select ( field => field . Name ) . ToArray ( ) ;
555+ EntityProfile . ReadOnly = rowListAttrSource . Where ( field => field . IsReadOnly ) . Select ( field => field . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
556+ EntityProfile . ClearFlag = rowListAttrSource . Where ( field => field . IsClearFlag ) . Select ( field => field . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
557557
558558 EntityProfile . OneToN =
559- rowList1NSource . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . ToArray ( ) ;
559+ rowList1NSource . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
560560 EntityProfile . OneToNRenames = rowList1NSource . Where ( relation => ! string . IsNullOrWhiteSpace ( relation . Rename ) )
561561 . ToDictionary ( relation => relation . Name , relation => relation . Rename ) ;
562- EntityProfile . OneToNReadOnly = rowList1NSource . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
562+ EntityProfile . OneToNReadOnly = rowList1NSource . Where ( relation => relation . IsReadOnly )
563+ . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
563564
564565 EntityProfile . NToOne =
565- rowListN1Source . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . ToArray ( ) ;
566+ rowListN1Source . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
566567 EntityProfile . NToOneRenames = rowListN1Source . Where ( relation => ! string . IsNullOrWhiteSpace ( relation . Rename ) )
567568 . ToDictionary ( relation => relation . Name , relation => relation . Rename ) ;
568- EntityProfile . NToOneFlatten = rowListN1Source . ToDictionary ( relation => relation . Name , relation => relation . IsFlatten ) ;
569- EntityProfile . NToOneReadOnly = rowListN1Source . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
569+ EntityProfile . NToOneFlatten = rowListN1Source . Where ( relation => relation . IsFlatten )
570+ . ToDictionary ( relation => relation . Name , relation => relation . IsFlatten ) ;
571+ EntityProfile . NToOneReadOnly = rowListN1Source . Where ( relation => relation . IsReadOnly )
572+ . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
570573
571574 EntityProfile . NToN =
572- RelationsNn . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . ToArray ( ) ;
575+ RelationsNn . Where ( relation => relation . IsSelected ) . Select ( relation => relation . Name ) . OrderBy ( p => p ) . ToArray ( ) ;
573576 EntityProfile . NToNRenames = RelationsNn . Where ( relation => ! string . IsNullOrWhiteSpace ( relation . Rename ) )
574577 . ToDictionary ( relation => relation . Name , relation => relation . Rename ) ;
575- EntityProfile . NToNReadOnly = RelationsNn . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
578+ EntityProfile . NToNReadOnly = RelationsNn . Where ( relation => relation . IsReadOnly )
579+ . ToDictionary ( relation => relation . Name , relation => relation . IsReadOnly ) ;
576580
577581 var toSelect = Relations1N . Where ( relation => relation . IsSelected ) . Select ( relation => relation . ToEntity )
578582 . Union ( RelationsN1 . Where ( relation => relation . IsSelected ) . Select ( relation => relation . ToEntity )
@@ -586,6 +590,34 @@ public void SaveFilter()
586590 }
587591
588592 callback ? . Invoke ( ) ;
593+
594+ SortSettings ( ) ;
595+ }
596+
597+ private void SortSettings ( )
598+ {
599+ EntityProfile . AttributeRenames = SortValues ( EntityProfile . AttributeRenames ) ;
600+ EntityProfile . AttributeLanguages = SortValues ( EntityProfile . AttributeLanguages ) ;
601+ EntityProfile . AttributeAnnotations = SortValues ( EntityProfile . AttributeAnnotations ) ;
602+ EntityProfile . OneToNRenames = SortValues ( EntityProfile . OneToNRenames ) ;
603+ EntityProfile . OneToNReadOnly = SortValues ( EntityProfile . OneToNReadOnly ) ;
604+ EntityProfile . NToOneRenames = SortValues ( EntityProfile . NToOneRenames ) ;
605+ EntityProfile . NToOneFlatten = SortValues ( EntityProfile . NToOneFlatten ) ;
606+ EntityProfile . NToOneReadOnly = SortValues ( EntityProfile . NToOneReadOnly ) ;
607+ EntityProfile . NToNRenames = SortValues ( EntityProfile . NToNRenames ) ;
608+ EntityProfile . NToNReadOnly = SortValues ( EntityProfile . NToNReadOnly ) ;
609+ }
610+
611+ private static IDictionary < string , T > SortValues < T > ( IDictionary < string , T > source )
612+ {
613+ var sorted = new SortedDictionary < string , T > ( ) ;
614+
615+ foreach ( var pair in source )
616+ {
617+ sorted [ pair . Key ] = pair . Value ;
618+ }
619+
620+ return sorted ;
589621 }
590622
591623 #region CRM
0 commit comments