1- // Copyright (C) 2003-2010 Xtensive LLC.
2- // All rights reserved .
3- // For conditions of distribution and use, see license .
1+ // Copyright (C) 2009-2020 Xtensive LLC.
2+ // This code is distributed under MIT license terms .
3+ // See the License.txt file in the project root for more information .
44// Created by: Alexis Kochetov
55// Created: 2009.02.27
66
@@ -924,13 +924,16 @@ private IList<Expression> GetStructureFields(
924924
925925 var result = new List < Expression > ( ) ;
926926 foreach ( PersistentFieldExpression fieldExpression in structureFields ) {
927- if ( ! structureType . GetProperties ( BindingFlags . Instance | BindingFlags . Public ) . Contains ( fieldExpression . UnderlyingProperty ) )
928- if ( ! context . Model . Types [ structureType ] . Fields [ fieldExpression . Name ] . IsDynalicallyDefined )
927+ if ( ! structureType . GetProperties ( BindingFlags . Instance | BindingFlags . Public ) . Contains ( fieldExpression . UnderlyingProperty ) ) {
928+ if ( ! context . Model . Types [ structureType ] . Fields [ fieldExpression . Name ] . IsDynamicallyDefined ) {
929929 continue ;
930+ }
931+ }
930932 Type nullableType = fieldExpression . Type . ToNullable ( ) ;
931933 Expression propertyAccessorExpression ;
932- if ( fieldExpression . UnderlyingProperty != null )
934+ if ( fieldExpression . UnderlyingProperty != null ) {
933935 propertyAccessorExpression = Expression . MakeMemberAccess ( Expression . Convert ( expression , structureType ) , fieldExpression . UnderlyingProperty ) ;
936+ }
934937 else {
935938 var attributes = structureType . GetCustomAttributes ( typeof ( DefaultMemberAttribute ) , true ) ;
936939 var indexerPropertyName = ( ( DefaultMemberAttribute ) attributes . Single ( ) ) . MemberName ;
@@ -945,23 +948,23 @@ private IList<Expression> GetStructureFields(
945948 nullableType ) ) ;
946949
947950 switch ( fieldExpression . GetMemberType ( ) ) {
948- case MemberType . Entity :
949- IEnumerable < Type > keyFieldTypes = context
950- . Model
951- . Types [ fieldExpression . Type ]
952- . Key
953- . TupleDescriptor ;
954- result . AddRange ( GetEntityFields ( memberExpression , keyFieldTypes ) ) ;
955- break ;
956- case MemberType . Structure :
957- var structureFieldExpression = ( StructureFieldExpression ) fieldExpression ;
958- result . AddRange ( GetStructureFields ( memberExpression , structureFieldExpression . Fields , structureFieldExpression . Type ) ) ;
959- break ;
960- case MemberType . Primitive :
961- result . Add ( memberExpression ) ;
962- break ;
963- default :
964- throw new NotSupportedException ( ) ;
951+ case MemberType . Entity :
952+ IEnumerable < Type > keyFieldTypes = context
953+ . Model
954+ . Types [ fieldExpression . Type ]
955+ . Key
956+ . TupleDescriptor ;
957+ result . AddRange ( GetEntityFields ( memberExpression , keyFieldTypes ) ) ;
958+ break ;
959+ case MemberType . Structure :
960+ var structureFieldExpression = ( StructureFieldExpression ) fieldExpression ;
961+ result . AddRange ( GetStructureFields ( memberExpression , structureFieldExpression . Fields , structureFieldExpression . Type ) ) ;
962+ break ;
963+ case MemberType . Primitive :
964+ result . Add ( memberExpression ) ;
965+ break ;
966+ default :
967+ throw new NotSupportedException ( ) ;
965968 }
966969 }
967970 return result ;
0 commit comments