Beispiel #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);
        }
        internal EntityDataSourceMemberPath(MetadataWorkspace ocWorkspace, EntityDataSourceMemberPath parent, EdmProperty property, bool isLocallyInteresting)
        {
            EntityDataSourceUtil.CheckArgumentNull(ocWorkspace, "ocWorkspace");
            EntityDataSourceUtil.CheckArgumentNull(property, "property");
            
            this.property = property;
            this.parent = parent;
            this.isLocallyInteresting = isLocallyInteresting;
            this.clrType = EntityDataSourceUtil.GetMemberClrType(ocWorkspace, property);
            this.isKey = IsPropertyAKey(property);

            // retrieve PropertyInfo (with respect to parent CLR type)
            StructuralType parentType = property.DeclaringType;
            Type parentClrType = EntityDataSourceUtil.GetClrType(ocWorkspace, parentType);

            this.propertyInfo = EntityDataSourceUtil.GetPropertyInfo(parentClrType, this.property.Name);
        }
Beispiel #3
0
        private static IEnumerable <EntityDataSourceColumn> GetColumns(EntitySet entitySet, EntityType entityType,
                                                                       MetadataWorkspace ocWorkspace, ReadOnlyCollection <EdmMember> interestingMembers)
        {
            List <EntityDataSourceColumn> columns = new List <EntityDataSourceColumn>();

            // Primitive and complex properties
            EntityDataSourceMemberPath parent = null; // top-level properties are not qualified
            Dictionary <EdmProperty, EntityDataSourcePropertyColumn> entityProperties = AddPropertyColumns(columns, ocWorkspace, parent, entityType.Properties, interestingMembers);

            // Navigation reference properties
            AddReferenceNavigationColumns(columns, ocWorkspace, entitySet, entityType);

            // Reference key properties
            AddReferenceKeyColumns(columns, ocWorkspace, entitySet, entityType, entityProperties);

            return(columns);
        }
        internal EntityDataSourceMemberPath(MetadataWorkspace ocWorkspace, EntityDataSourceMemberPath parent, EdmProperty property, bool isLocallyInteresting)
        {
            EntityDataSourceUtil.CheckArgumentNull(ocWorkspace, "ocWorkspace");
            EntityDataSourceUtil.CheckArgumentNull(property, "property");

            this.property             = property;
            this.parent               = parent;
            this.isLocallyInteresting = isLocallyInteresting;
            this.clrType              = EntityDataSourceUtil.GetMemberClrType(ocWorkspace, property);
            this.isKey = IsPropertyAKey(property);

            // retrieve PropertyInfo (with respect to parent CLR type)
            StructuralType parentType    = property.DeclaringType;
            Type           parentClrType = EntityDataSourceUtil.GetClrType(ocWorkspace, parentType);

            this.propertyInfo = EntityDataSourceUtil.GetPropertyInfo(parentClrType, this.property.Name);
        }
 internal EntityDataSourcePropertyColumn(EntityDataSourceMemberPath memberPath)
     : base(EntityDataSourceUtil.CheckArgumentNull(memberPath, "memberPath").GetDescription())
 {
     this.memberPath = memberPath;
 }
Beispiel #6
0
 internal EntityDataSourcePropertyColumn(EntityDataSourceMemberPath memberPath)
     : base(EntityDataSourceUtil.CheckArgumentNull(memberPath, "memberPath").GetDescription())
 {
     this.memberPath = memberPath;
 }