Exemple #1
0
        // <summary>
        // Handles extent expressions (these are the terminal nodes in update mapping views). This handler
        // retrieves the changes from the grouper.
        // </summary>
        // <param name="node"> Extent expression node </param>
        public override ChangeNode Visit(DbScanExpression node)
        {
            Check.NotNull(node, "node");

            // Gets modifications requested for this extent from the grouper.
            var extent = node.Target;
            var extentModifications = UpdateTranslator.GetExtentModifications(extent);

            if (null == extentModifications.Placeholder)
            {
                // Bootstrap placeholder (essentially a record for the extent populated with default values).
                extentModifications.Placeholder = ExtentPlaceholderCreator.CreatePlaceholder(extent);
            }

            return(extentModifications);
        }
Exemple #2
0
            /// <summary>
            /// Creates a record for an extent containing default values. Assumes the extent is either
            /// a relationship set or an entity set.
            /// </summary>
            /// <remarks>
            /// Each scalar value appearing in the record is a <see cref="DbConstantExpression" />. A placeholder is created by recursively
            /// building a record, so an entity record type will return a new record (<see cref="DbNewInstanceExpression" />)
            /// consisting of some recursively built record for each column in the type.
            /// </remarks>
            /// <param name="extent">Extent</param>
            /// <param name="parent">Command tree used to generate portions of the record</param>
            /// <returns>A default record for the </returns>
            internal static PropagatorResult CreatePlaceholder(EntitySetBase extent, UpdateTranslator parent)
            {
                EntityUtil.CheckArgumentNull(extent, "extent");

                ExtentPlaceholderCreator creator = new ExtentPlaceholderCreator(parent);

                AssociationSet associationSet = extent as AssociationSet;

                if (null != associationSet)
                {
                    return(creator.CreateAssociationSetPlaceholder(associationSet));
                }

                EntitySet entitySet = extent as EntitySet;

                if (null != entitySet)
                {
                    return(creator.CreateEntitySetPlaceholder(entitySet));
                }

                throw EntityUtil.NotSupported(System.Data.Entity.Strings.Update_UnsupportedExtentType(
                                                  extent.Name, extent.GetType().Name));
            }
            // <summary>
            // Creates a record for an extent containing default values. Assumes the extent is either
            // a relationship set or an entity set.
            // </summary>
            // <remarks>
            // Each scalar value appearing in the record is a <see cref="DbConstantExpression" />. A placeholder is created by recursively
            // building a record, so an entity record type will return a new record (<see cref="DbNewInstanceExpression" />)
            // consisting of some recursively built record for each column in the type.
            // </remarks>
            // <param name="extent"> Extent </param>
            // <returns> A default record for the </returns>
            internal static PropagatorResult CreatePlaceholder(EntitySetBase extent)
            {
                DebugCheck.NotNull(extent);

                var creator = new ExtentPlaceholderCreator();

                var associationSet = extent as AssociationSet;

                if (null != associationSet)
                {
                    return(creator.CreateAssociationSetPlaceholder(associationSet));
                }

                var entitySet = extent as EntitySet;

                if (null != entitySet)
                {
                    return(creator.CreateEntitySetPlaceholder(entitySet));
                }

                throw new NotSupportedException(
                          Strings.Update_UnsupportedExtentType(
                              extent.Name, extent.GetType().Name));
            }
            /// <summary>
            /// Creates a record for an extent containing default values. Assumes the extent is either
            /// a relationship set or an entity set.
            /// </summary>
            /// <remarks>
            /// Each scalar value appearing in the record is a <see cref="DbConstantExpression" />. A placeholder is created by recursively
            /// building a record, so an entity record type will return a new record (<see cref="DbNewInstanceExpression" />)
            /// consisting of some recursively built record for each column in the type.
            /// </remarks>
            /// <param name="extent">Extent</param>
            /// <param name="parent">Command tree used to generate portions of the record</param>
            /// <returns>A default record for the </returns>
            internal static PropagatorResult CreatePlaceholder(EntitySetBase extent, UpdateTranslator parent)
            {
                EntityUtil.CheckArgumentNull(extent, "extent");

                ExtentPlaceholderCreator creator = new ExtentPlaceholderCreator(parent);

                AssociationSet associationSet = extent as AssociationSet;
                if (null != associationSet)
                {
                    return creator.CreateAssociationSetPlaceholder(associationSet);
                }

                EntitySet entitySet = extent as EntitySet;
                if (null != entitySet)
                {
                    return creator.CreateEntitySetPlaceholder(entitySet);
                }

                throw EntityUtil.NotSupported(System.Data.Entity.Strings.Update_UnsupportedExtentType(
                    extent.Name, extent.GetType().Name));
            }
            /// <summary>
            ///     Creates a record for an extent containing default values. Assumes the extent is either
            ///     a relationship set or an entity set.
            /// </summary>
            /// <remarks>
            ///     Each scalar value appearing in the record is a <see cref="DbConstantExpression" />. A placeholder is created by recursively
            ///     building a record, so an entity record type will return a new record (<see cref="DbNewInstanceExpression" />)
            ///     consisting of some recursively built record for each column in the type.
            /// </remarks>
            /// <param name="extent"> Extent </param>
            /// <returns> A default record for the </returns>
            internal static PropagatorResult CreatePlaceholder(EntitySetBase extent)
            {
                DebugCheck.NotNull(extent);

                var creator = new ExtentPlaceholderCreator();

                var associationSet = extent as AssociationSet;
                if (null != associationSet)
                {
                    return creator.CreateAssociationSetPlaceholder(associationSet);
                }

                var entitySet = extent as EntitySet;
                if (null != entitySet)
                {
                    return creator.CreateEntitySetPlaceholder(entitySet);
                }

                throw new NotSupportedException(
                    Strings.Update_UnsupportedExtentType(
                        extent.Name, extent.GetType().Name));
            }