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);
        }
        public List <MetaPropertyInstruction> ConvertToInstructions(MetaEntityNamespaceCollection namespaces, Boolean includeItems = true)
        {
            List <MetaPropertyInstruction> output = new List <MetaPropertyInstruction>();

            CheckClassDefinition(namespaces, EntityClassName);

            output.Add(new MetaPropertyInstruction(nameof(name), name));
            output.Add(new MetaPropertyInstruction(nameof(EntityClassName), EntityClassName));

            foreach (var setter in Setters)
            {
                var setterProperty = EntityClassDefinition.FindProperty(setter.name);

                output.Add(new MetaPropertyInstruction(setter, setterProperty));
            }

            if (includeItems)
            {
                foreach (var item in Items)
                {
                    var itemProperty = EntityClassDefinition.FindProperty(item.name);
                    if (itemProperty.type.HasFlag(MetaEntityClassPropertyType.collection))
                    {
                        List <MetaPropertyInstruction> itemInstructions = new List <MetaPropertyInstruction>();
                        foreach (var subitem in item.Items)
                        {
                            var subinstructions = subitem.ConvertToInstructions(namespaces);
                            if (subinstructions.Any())
                            {
                                itemInstructions.Add(new MetaPropertyInstruction(subitem.name, subinstructions));
                            }
                        }
                        if (itemInstructions.Any())
                        {
                            output.Add(new MetaPropertyInstruction(itemProperty.name, itemInstructions));
                        }
                    }
                    else
                    {
                        var subinstructions = item.ConvertToInstructions(namespaces);
                        output.Add(new MetaPropertyInstruction(itemProperty.name, subinstructions));
                    }
                }
            }

            return(output);
        }