File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Orm/Xtensive.Orm/Orm/Model Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 1- // Copyright (C) 2007-2021 Xtensive LLC.
1+ // Copyright (C) 2007-2022 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44// Created by: Dmitri Maximov
@@ -627,6 +627,7 @@ public ColumnInfoCollection Columns
627627
628628 var result = new ColumnInfoCollection ( this , "Columns" ) ;
629629 GetColumns ( result ) ;
630+ columns = result ;
630631 return result ;
631632 }
632633 }
@@ -660,8 +661,8 @@ public override void UpdateState()
660661 Fields . UpdateState ( ) ;
661662 if ( column != null )
662663 column . UpdateState ( ) ;
663- columns = new ColumnInfoCollection ( this , "Columns" ) ;
664- GetColumns ( columns ) ;
664+ columns ? . Clear ( ) ; // To prevent event handler leak
665+ columns = null ;
665666
666667 HasImmediateValidators = validators . Count > 0 && validators . Any ( v => v . IsImmediate ) ;
667668
Original file line number Diff line number Diff line change 1- // Copyright (C) 2007-2020 Xtensive LLC.
1+ // Copyright (C) 2007-2022 Xtensive LLC.
22// This code is distributed under MIT license terms.
33// See the License.txt file in the project root for more information.
44// Created by: Dmitri Maximov
@@ -38,7 +38,7 @@ public sealed class TypeInfo : SchemaMappedNode
3838 /// </summary>
3939 public const int MinTypeId = 100 ;
4040
41- private ColumnInfoCollection columns ;
41+ private readonly ColumnInfoCollection columns ;
4242 private readonly FieldMap fieldMap ;
4343 private readonly FieldInfoCollection fields ;
4444 private readonly TypeIndexInfoCollection indexes ;
@@ -747,8 +747,8 @@ private bool GetIsLeaf()
747747
748748 private void CreateTupleDescriptor ( )
749749 {
750- var orderedColumns = columns . OrderBy ( c => c . Field . MappingInfo . Offset ) ;
751- columns = new ColumnInfoCollection ( this , "Columns" ) ;
750+ var orderedColumns = columns . OrderBy ( c => c . Field . MappingInfo . Offset ) . ToList ( columns . Count ) ;
751+ columns . Clear ( ) ; // To prevent event handler leak
752752 columns . AddRange ( orderedColumns ) ;
753753 TupleDescriptor = TupleDescriptor . Create (
754754 Columns . Select ( c => c . ValueType ) . ToArray ( Columns . Count ) ) ;
You can’t perform that action at this time.
0 commit comments