private static StoredFieldInfo ConvertField(FieldInfo source)
        {
            var nestedFields = source.Fields
                               .Where(field => field.Parent == source);
            var result = new StoredFieldInfo {
                Name         = source.Name,
                MappingName  = source.MappingName,
                PropertyName = source.UnderlyingProperty != null ? source.UnderlyingProperty.Name : null,
                OriginalName = source.OriginalName,
                ValueType    = source.ValueType.GetFullName(),
                ItemType     = GetTypeFullName(source.ItemType),
                Fields       = nestedFields.Select(ConvertField).ToArray(),
                Length       = source.Length.HasValue ? source.Length.Value : 0,
                IsEntity     = source.IsEntity,
                IsEntitySet  = source.IsEntitySet,
                IsEnum       = source.IsEnum,
                IsExplicit   = source.IsExplicit,
                IsInterfaceImplementation = source.IsInterfaceImplementation,
                IsLazyLoad   = source.IsLazyLoad,
                IsNullable   = source.IsNullable,
                IsPrimaryKey = source.IsPrimaryKey,
                IsPrimitive  = source.IsPrimitive,
                IsStructure  = source.IsStructure,
                IsSystem     = source.IsSystem,
                IsTypeId     = source.IsTypeId,
            };

            return(result);
        }
 private void UpdateFieldDeclaringType(StoredFieldInfo field, StoredTypeInfo type)
 {
     field.DeclaringType = type;
     foreach (var nestedField in field.Fields)
     {
         UpdateFieldDeclaringType(nestedField, type);
     }
 }
        private void UpdateNestedFields(StoredFieldInfo field)
        {
            if (field.Fields == null)
            {
                field.Fields = ArrayUtils <StoredFieldInfo> .EmptyArray;
                return;
            }

            foreach (var nestedField in field.Fields)
            {
                nestedField.Parent = field;
                UpdateNestedFields(nestedField);
            }
        }