示例#1
0
        /// <summary>
        /// Gets the EntityDataKey for the specified association role.
        /// </summary>
        /// <param name="roleName">The association role name.</param>
        /// <returns>EntityDataKey for the association role.</returns>
        public EntityDataKey GetRoleKey(string roleName)
        {
            int           ordinal = this.GetRoleNameOrdinal(roleName);
            EntityDataKey key     = this.data[ordinal];

            if (key == null)
            {
                key = new EntityDataKey(this.GetKeyNamesForRoleName(roleName));
                this.data[ordinal] = key;
            }

            return(key);
        }
示例#2
0
            internal EntitySetDataRowData(EntityDataKey key, string[] nonKeyPropertyPaths, string[] dynamicPropertyPaths, string fullEntityTypeName)
            {
                this.dynamicData          = new Dictionary <string, object>();
                this.dynamicPropertyPaths = dynamicPropertyPaths;
                this.nonKeyPropertyPaths  = nonKeyPropertyPaths;
                this.key = key;
                this.fullEntityTypeName = fullEntityTypeName;

                // Initialize all the data for property non collection non key property paths to unitialized
                foreach (string propertyPath in this.nonKeyPropertyPaths)
                {
                    this.dynamicData.Add(propertyPath, UninitializedData.Value);
                }
            }
示例#3
0
        /// <summary>
        /// Sets the EntityDataKey for the specified association role.
        /// </summary>
        /// <param name="roleName">The association role name.</param>
        /// <param name="key">EntityDataKey for the association role.</param>
        public void SetRoleKey(string roleName, EntityDataKey key)
        {
            ExceptionUtilities.CheckArgumentNotNull(key, "key");
            int ordinal = this.GetRoleNameOrdinal(roleName);

            List <string> expectedKeyNames = this.GetKeyNamesForRoleName(roleName).ToList();

            if (expectedKeyNames.Count != key.KeyNames.Count ||
                expectedKeyNames.Join(key.KeyNames, n1 => n1, n2 => n2, (n1, n2) => n1).Count() != expectedKeyNames.Count)
            {
                throw new TaupoArgumentException("Specified key does not match key metadata for the role '" + roleName + "'.");
            }

            this.data[ordinal] = key;
        }
示例#4
0
        /// <summary>
        /// Gets the related keys for the given roleName in an association(denoted by associationSetName), given this end's key.
        /// </summary>
        /// <param name="data">The EntityContainerData which contains AssociationSetData.</param>
        /// <param name="associationSetName">The name of the association set.</param>
        /// <param name="roleName">The roleName of the known end.</param>
        /// <param name="roleKey">The key for the role of the known end.</param>
        /// <returns>The Related keys of the other end.</returns>
        public static IEnumerable <EntityDataKey> GetRelatedKeys(this EntityContainerData data, string associationSetName, string roleName, EntityDataKey roleKey)
        {
            ExceptionUtilities.CheckArgumentNotNull(data, "data");
            ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(associationSetName, "associationSetName");
            ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(roleName, "roleName");
            ExceptionUtilities.CheckArgumentNotNull(roleKey, "roleKey");

            var    associationSetData = data.GetAssociationSetData(associationSetName);
            string otherRoleName      = associationSetData.AssociationSet.AssociationType.Ends.Where(e => e.RoleName != roleName).Single().RoleName;

            return(associationSetData.Rows.Where(r => roleKey.Equals(r.GetRoleKey(roleName))).Select(r => r.GetRoleKey(otherRoleName)));
        }