// Constructors /// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="model">The model.</param> /// <param name="typeAttributes">The type attributes.</param> public TypeInfo(DomainModel model, TypeAttributes typeAttributes) { this.model = model; attributes = typeAttributes; columns = new ColumnInfoCollection(this, "Columns"); fields = new FieldInfoCollection(this, "Fields"); fieldMap = IsEntity ? new FieldMap() : FieldMap.Empty; indexes = new TypeIndexInfoCollection(this, "Indexes"); affectedIndexes = new NodeCollection <IndexInfo>(this, "AffectedIndexes"); }
/// <summary> /// Resolves this instance to <see cref="TypeInfo"/> object within specified <paramref name="model"/>. /// </summary> /// <param name="model">Domain model.</param> public TypeInfo Resolve(DomainModel model) { TypeInfo type; if (!model.Types.TryGetValue(TypeName, out type)) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "type", TypeName)); } return(type); }
/// <summary> /// Resolves this instance to <see cref="FieldInfo"/> object within specified <paramref name="model"/>. /// </summary> /// <param name="model">Domain model.</param> public FieldInfo Resolve(DomainModel model) { var type = TypeRef.Resolve(model); FieldInfo field; if (!type.Fields.TryGetValue(FieldName, out field)) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "field", FieldName)); } return(field); }
/// <summary> /// Resolves this instance to <see cref="ColumnInfo"/> object within specified <paramref name="model"/>. /// </summary> /// <param name="model">Domain model.</param> public ColumnInfo Resolve(DomainModel model) { TypeInfo type; if (!model.Types.TryGetValue(TypeName, out type)) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "type", TypeName)); } FieldInfo field; if (!type.Fields.TryGetValue(FieldName, out field)) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "field", FieldName)); } if (field.Column == null) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "column", ColumnName)); } return(field.Column); }
/// <summary> /// Resolves this instance to <see cref="IndexInfo"/> object within specified <paramref name="model"/>. /// </summary> /// <param name="model">Domain model.</param> public IndexInfo Resolve(DomainModel model) { TypeInfo type; if (!model.Types.TryGetValue(TypeName, out type)) { throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "type", TypeName)); } IndexInfo index; if (!type.Indexes.TryGetValue(IndexName, out index)) { var hierarchy = type.Hierarchy; if (hierarchy != null && hierarchy.InheritanceSchema == InheritanceSchema.SingleTable && hierarchy.Root.Indexes.TryGetValue(IndexName, out index)) { return(index); } throw new InvalidOperationException(string.Format(Strings.ExCouldNotResolveXYWithinDomain, "index", IndexName)); } return(index); }
/// <summary> /// Visits domain model. /// </summary> /// <param name="domainModel">The domain model.</param> /// <returns>Visit result.</returns> protected abstract TResult VisitDomainModel(DomainModel domainModel);
/// <summary> /// Converts speicified <see cref="DomainModel"/> to corresponding <see cref="StoredDomainModel"/>. /// </summary> /// <param name="model">The model to convert.</param> /// <param name="typeIdRegistry">Type identifier registry.</param> /// <param name="filter">Model filter.</param> /// <returns>A result of conversion.</returns> public static StoredDomainModel ToStoredModel(this DomainModel model, TypeIdRegistry typeIdRegistry = null, Func <TypeInfo, bool> filter = null) { return(new ConverterToStoredModel().Convert(model, typeIdRegistry, filter)); }