コード例 #1
0
        /// <summary>
        /// Gets the property to which the attribute's target is redirected, throwing an exception if the property does not exist.
        /// </summary>
        /// <returns>The property to which the attribute's target is redirected.</returns>
        /// <exception cref="MappingException">The property does not exist.</exception>
        public PropertyInfo GetMappedProperty()
        {
            var mappedProperty = DeclaringType.GetProperty(MappedPropertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (mappedProperty == null)
            {
                var message = string.Format("The member redirects LINQ queries to '{0}.{1}', which does not exist.", DeclaringType, MappedPropertyName);
                throw new MappingException(message);
            }
            return(mappedProperty);
        }