public SlicedEntityMetadata([NotNull] string name, [NotNull] EntitySchema schema, [NotNull] IEnumerable <EntityAssociation> associations, [NotNull] ConnectorParameters connectorParameters, ApplicationSchemaDefinition appSchema, IEnumerable <SlicedEntityMetadata> innerMetadatas, int?fetchLimit = 300, SlicedEntityMetadata unionSchema = null) : base(name, schema, associations, connectorParameters) { _appSchema = appSchema; _fetchLimit = fetchLimit; _innerMetadatas.AddRange(innerMetadatas); _unionSchema = unionSchema; }
public static SlicedEntityMetadata GetInstance(EntityMetadata entityMetadata, ApplicationSchemaDefinition appSchema, int?fetchLimit = 300, bool isUnionSchema = false) { var entityAttributes = entityMetadata.Schema.Attributes; var usedRelationships = new HashSet <EntityAssociation>(); ISet <EntityAttribute> usedAttributes = new HashSet <EntityAttribute>(); foreach (var field in appSchema.NonRelationshipFields) { if (field.Attribute.StartsWith("#null")) { usedAttributes.Add(new EntityAttribute(field.Attribute, "varchar", false, true, ConnectorParameters.DefaultInstance(), null)); } else { var entityAttribute = entityAttributes.FirstOrDefault(r => field.Attribute == r.Name); if (entityAttribute != null) { usedAttributes.Add(entityAttribute); } } } usedAttributes.Add(entityMetadata.Schema.IdAttribute); if (!isUnionSchema) { usedAttributes.Add(entityMetadata.Schema.RowstampAttribute); } usedRelationships.UnionWith(HandleAssociations(appSchema.Associations, entityMetadata)); usedRelationships.UnionWith(HandleCompositions(appSchema.Compositions, entityMetadata, appSchema)); var result = SlicedRelationshipBuilderHelper.HandleRelationshipFields(appSchema.RelationshipFields.Select(r => r.Attribute), entityMetadata); usedRelationships.UnionWith(result.DirectRelationships); var schema = new EntitySchema(entityMetadata.Name, usedAttributes, entityMetadata.Schema.IdAttribute.Name, false, false, entityMetadata.Schema.WhereClause, entityMetadata.Schema.ParentEntity, !isUnionSchema); SlicedEntityMetadata unionSchema = null; if (appSchema.UnionSchema != null) { unionSchema = GetUnionInstance(appSchema.UnionSchema); } return(new SlicedEntityMetadata(entityMetadata.Name, schema, usedRelationships, entityMetadata.ConnectorParameters, appSchema, result.InnerEntityMetadatas, fetchLimit, unionSchema)); }