protected override void AddUpgradeHints(Xtensive.Collections.ISet <UpgradeHint> hints) { if (runningVersion == "2") { Version1To2Hints.ForEach(hint => hints.Add(hint)); } }
private LocalCollectionExpression BuildLocalCollectionExpression(Type type, Xtensive.Collections.ISet <Type> processedTypes, ref int columnIndex, MemberInfo parentMember, ref IEnumerable <Type> types) { if (type.IsAssignableFrom(typeof(Key))) { throw new InvalidOperationException(String.Format(Strings.ExUnableToStoreUntypedKeyToStorage, typeof(Ref <>).GetShortName())); } if (!processedTypes.Add(type)) { throw new InvalidOperationException(String.Format(Strings.ExUnableToPersistTypeXBecauseOfLoopReference, type.FullName)); } IEnumerable <MemberInfo> members = type .GetProperties(BindingFlags.Instance | BindingFlags.Public) .Where(propertyInfo => propertyInfo.CanRead) .Cast <MemberInfo>() .Concat(type.GetFields(BindingFlags.Instance | BindingFlags.Public)); var fields = new Dictionary <MemberInfo, IMappedExpression>(); foreach (MemberInfo memberInfo in members) { var propertyInfo = memberInfo as PropertyInfo; Type memberType = propertyInfo == null ? ((FieldInfo)memberInfo).FieldType : propertyInfo.PropertyType; if (IsPersistableType(memberType)) { IMappedExpression expression = BuildField(memberType, ref columnIndex, ref types); fields.Add(memberInfo, expression); } else { LocalCollectionExpression collectionExpression = BuildLocalCollectionExpression(memberType, new Set <Type>(processedTypes), ref columnIndex, memberInfo, ref types); fields.Add(memberInfo, collectionExpression); } } if (fields.Count == 0) { throw new InvalidOperationException(String.Format(Strings.ExTypeXDoesNotHasAnyPublicReadablePropertiesOrFieldsSoItCanTBePersistedToStorage, type.FullName)); } var result = new LocalCollectionExpression(type, parentMember, sourceExpression); result.Fields = fields; return(result); }
protected override void AddUpgradeHints(Xtensive.Collections.ISet <UpgradeHint> hints) { _ = hints.Add(new RenameTypeHint("Xtensive.Orm.Tests.Upgrade.PrimaryKeyModel.Version1.Book", typeof(PrimaryKeyModel.Version2PerformSafely.Book))); _ = hints.Add(new RemoveTypeHint("Xtensive.Orm.Tests.Upgrade.PrimaryKeyModel.Version1.Category")); _ = hints.Add(new RemoveFieldHint("Xtensive.Orm.Tests.Upgrade.PrimaryKeyModel.Version1.Book", "Category")); }