コード例 #1
0
        /// <summary>
        /// Gets an object that represents a nested complex property of this property.
        /// </summary>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbComplexPropertyEntry ComplexProperty(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbComplexPropertyEntry.Create(InternalPropertyEntry.Property(propertyName, null, requireComplex: true)));
        }
コード例 #2
0
        /// <summary>
        /// Gets an object that represents a nested property of this property.
        /// This method can be used for both scalar or complex properties.
        /// </summary>
        /// <typeparam name="TNestedProperty"> The type of the nested property. </typeparam>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbPropertyEntry <TEntity, TNestedProperty> Property <TNestedProperty>(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbPropertyEntry <TEntity, TNestedProperty> .Create(
                     InternalPropertyEntry.Property(propertyName, typeof(TNestedProperty))));
        }
コード例 #3
0
        /// <summary>
        /// Gets an object that represents a nested complex property of this property.
        /// </summary>
        /// <typeparam name="TNestedComplexProperty"> The type of the nested property. </typeparam>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbComplexPropertyEntry <TEntity, TNestedComplexProperty> ComplexProperty <TNestedComplexProperty>(
            string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return
                (DbComplexPropertyEntry <TEntity, TNestedComplexProperty> .Create(
                     InternalPropertyEntry.Property(propertyName, typeof(TNestedComplexProperty), requireComplex: true)));
        }
コード例 #4
0
 protected override void ValidateProperties(
     EntityValidationContext entityValidationContext,
     InternalPropertyEntry parentProperty,
     List <DbValidationError> validationErrors)
 {
     foreach (PropertyValidator propertyValidator in this.PropertyValidators)
     {
         InternalPropertyEntry internalPropertyEntry = parentProperty.Property(propertyValidator.PropertyName, (Type)null, false);
         validationErrors.AddRange(propertyValidator.Validate(entityValidationContext, (InternalMemberEntry)internalPropertyEntry));
     }
 }
コード例 #5
0
        /// <summary>
        ///     Validates type properties. Any validation errors will be added to <paramref name = "validationErrors" />
        ///     collection.
        /// </summary>
        /// <param name = "entityValidationContext">
        ///     Validation context. Must not be null.
        /// </param>
        /// <param name = "validationErrors">
        ///     Collection of validation errors. Any validation errors will be added to it.
        /// </param>
        /// <param name = "parentProperty">The entry for the complex property. Null if validating an entity.</param>
        /// <remarks>
        ///     Note that <paramref name = "validationErrors" /> will be modified by this method. Errors should be only added,
        ///     never removed or changed. Taking a collection as a modifiable parameter saves a couple of memory allocations
        ///     and a merge of validation error lists per entity.
        /// </remarks>
        protected override void ValidateProperties(
            EntityValidationContext entityValidationContext, InternalPropertyEntry parentProperty,
            List<DbValidationError> validationErrors)
        {
            Contract.Assert(parentProperty.EntryMetadata.IsComplex, "A complex type expected.");
            Contract.Assert(parentProperty.CurrentValue != null);

            foreach (var validator in PropertyValidators)
            {
                var complexProperty = parentProperty.Property(validator.PropertyName);
                validationErrors.AddRange(validator.Validate(entityValidationContext, complexProperty));
            }
        }
コード例 #6
0
        /// <summary>
        ///     Validates type properties. Any validation errors will be added to <paramref name="validationErrors" />
        ///     collection.
        /// </summary>
        /// <param name="entityValidationContext"> Validation context. Must not be null. </param>
        /// <param name="validationErrors"> Collection of validation errors. Any validation errors will be added to it. </param>
        /// <param name="parentProperty"> The entry for the complex property. Null if validating an entity. </param>
        /// <remarks>
        ///     Note that <paramref name="validationErrors" /> will be modified by this method. Errors should be only added,
        ///     never removed or changed. Taking a collection as a modifiable parameter saves a couple of memory allocations
        ///     and a merge of validation error lists per entity.
        /// </remarks>
        protected override void ValidateProperties(
            EntityValidationContext entityValidationContext, InternalPropertyEntry parentProperty,
            List <DbValidationError> validationErrors)
        {
            DebugCheck.NotNull(entityValidationContext);
            DebugCheck.NotNull(parentProperty);
            DebugCheck.NotNull(validationErrors);

            Debug.Assert(parentProperty.EntryMetadata.IsComplex, "A complex type expected.");
            Debug.Assert(parentProperty.CurrentValue != null);

            foreach (var validator in PropertyValidators)
            {
                var complexProperty = parentProperty.Property(validator.PropertyName);
                validationErrors.AddRange(validator.Validate(entityValidationContext, complexProperty));
            }
        }
コード例 #7
0
        /// <summary>
        /// Gets an object that represents a nested property of this property.
        /// This method can be used for both scalar or complex properties.
        /// </summary>
        /// <param name="propertyName"> The name of the nested property. </param>
        /// <returns> An object representing the nested property. </returns>
        public DbPropertyEntry Property(string propertyName)
        {
            Check.NotEmpty(propertyName, "propertyName");

            return(DbPropertyEntry.Create(InternalPropertyEntry.Property(propertyName)));
        }