Пример #1
0
        /// <summary>
        /// Appends the key expression for the given entity to the given <see cref="StringBuilder"/>
        /// </summary>
        /// <param name="entity">The entity to build the key expression from.</param>
        /// <param name="builder">The builder to append onto.</param>
        internal void AppendKeyExpression(IEdmStructuredValue entity, StringBuilder builder)
        {
            Debug.Assert(entity != null, "entity != null");
            Debug.Assert(builder != null, "builder != null");

            IEdmEntityTypeReference edmEntityTypeReference = entity.Type as IEdmEntityTypeReference;

            if (edmEntityTypeReference == null || !edmEntityTypeReference.Key().Any())
            {
                throw Error.Argument(ErrorStrings.Content_EntityWithoutKey, "entity");
            }

            this.AppendKeyExpression(edmEntityTypeReference.Key().ToList(), p => p.Name, p => GetPropertyValue(entity.FindPropertyValue(p.Name), entity.Type), builder);
        }