public DataSet GetDataSet(MetaEntityNamespaceCollection namespaces)
        {
            DataTable valueTable = GetVerticalDataTable(namespaces);


            DataSet output = new DataSet();

            output.Tables.Add(valueTable);

            foreach (var item in Items)
            {
                var itemProperty = EntityClassDefinition.FindProperty(item.name);
                if (itemProperty.type.HasFlag(MetaEntityClassPropertyType.collection))
                {
                    MetaEntityClass itemClass = namespaces.FindClass(itemProperty.PropertyTypeName);

                    DataTable collectionTable = itemClass.CreateDataTableForEntities(MetaEntityClassPropertyType.valueCollection);
                    collectionTable.SetTitle(itemProperty.name);

                    foreach (var subitem in item.Items)
                    {
                        itemClass.CreateDataTableRow(collectionTable, subitem, MetaEntityClassPropertyType.valueCollection);
                    }
                    output.Tables.Add(collectionTable);
                }
                else
                {
                    var itemVerticalTable = item.GetVerticalDataTable(namespaces, itemProperty.name);

                    output.Tables.Add(itemVerticalTable);
                }
            }

            return(output);
        }
Beispiel #2
0
        public override IMetaEntityExpressionTarget SelectTarget(string expressionPathNode)
        {
            if (MetaEntityTools.IsMultinodeExpressionPath(expressionPathNode))
            {
                return(Parent.SelectTargetByPath(expressionPathNode));
            }

            var head = Declarations.FirstOrDefault(x => x.name.Equals(expressionPathNode));

            if (head == null)
            {
                MetaEntityClass item = new MetaEntityClass();
                item.name   = expressionPathNode;
                item.Parent = this;

                Declarations.Add(item);
                head = item;
            }


            return(head);
        }
        /// <summary>
        /// Collects all classes from properties and their
        /// </summary>
        /// <param name="rootClass">The root class.</param>
        /// <param name="namespaces">The namespaces.</param>
        /// <param name="includeSelf">if set to <c>true</c> [include self].</param>
        /// <returns></returns>
        public static List <MetaEntityClass> CollectRelevantClasses(this MetaEntityClass rootClass, MetaEntityNamespaceCollection namespaces, Boolean includeSelf = true)
        {
            List <MetaEntityClass> output = new List <MetaEntityClass>();

            if (includeSelf)
            {
                output.Add(rootClass);
            }

            List <MetaEntityClass> iteration = new List <MetaEntityClass>()
            {
                rootClass
            };

            while (iteration.Any())
            {
                List <MetaEntityClass> next_iteration = new List <MetaEntityClass>();
                foreach (var cf in iteration)
                {
                    foreach (MetaEntityClassProperty property in cf.Properties)
                    {
                        if (property.type.HasFlag(MetaEntityClassPropertyType.entity))
                        {
                            var entityClass = namespaces.FindClass(property.ValueTypeName);
                            if (!output.Any(x => x.GetNamepath() == entityClass.GetNamepath()))
                            {
                                next_iteration.Add(entityClass);
                                output.Add(entityClass);
                            }
                        }
                    }
                }

                iteration = next_iteration;
            }

            return(output);
        }