Esempio n. 1
0
        // Adds element to 'columns' for every element of 'properties'. Also returns a map from properties
        // at this level to the corresponding columns.
        private static Dictionary <EdmProperty, EntityDataSourcePropertyColumn> AddPropertyColumns(List <EntityDataSourceColumn> columns, MetadataWorkspace ocWorkspace, EntityDataSourceMemberPath parent, IEnumerable <EdmProperty> properties, ReadOnlyCollection <EdmMember> interestingMembers)
        {
            Dictionary <EdmProperty, EntityDataSourcePropertyColumn> result = new Dictionary <EdmProperty, EntityDataSourcePropertyColumn>();

            foreach (EdmProperty property in properties)
            {
                bool isLocallyInteresting = interestingMembers.Contains(property);

                EntityDataSourceMemberPath prefix = new EntityDataSourceMemberPath(ocWorkspace, parent, property, isLocallyInteresting);
                EdmType propertyType = property.TypeUsage.EdmType;

                // add column for this entity property
                EntityDataSourcePropertyColumn propertyColumn = new EntityDataSourcePropertyColumn(prefix);
                columns.Add(propertyColumn);
                result.Add(property, propertyColumn);

                if (propertyType.BuiltInTypeKind == BuiltInTypeKind.ComplexType)
                {
                    // add nested properties
                    // prepend the property name to the members of the complex type
                    AddPropertyColumns(columns, ocWorkspace, prefix, ((ComplexType)propertyType).Properties, interestingMembers);
                }
                // other property types are not currently supported (or possible in EF V1 for that matter)
            }

            return(result);
        }
Esempio n. 2
0
        internal EntityDataSourceViewSchema(EntityDataSourceWrapperCollection wrappers)
        {
            DataColumn                   column;
            List <DataColumn>            keys       = new List <DataColumn>();
            PropertyDescriptorCollection properties = wrappers.GetItemProperties(null);
            MetadataWorkspace            workspace  = wrappers.Context.MetadataWorkspace;

            foreach (EntityDataSourceWrapperPropertyDescriptor property in properties)
            {
                Type propertyType = property.PropertyType;
                column = ConstructColumn(property);

                column.AllowDBNull = property.Column.IsNullable;

                EntityDataSourcePropertyColumn propertyColumn = property.Column as EntityDataSourcePropertyColumn;
                if (null != propertyColumn && propertyColumn.IsKey)
                {
                    keys.Add(column);
                }
                Columns.Add(column);
            }
            this.PrimaryKey = keys.ToArray();
        }