Ejemplo n.º 1
0
        // <summary>
        // Constructs a wrapper as part of the materialization process.  This constructor is only used
        // during materialization where it is known that the entity being wrapped is newly constructed.
        // This means that some checks are not performed that might be needed when thw wrapper is
        // created at other times, and information such as the identity type is passed in because
        // it is readily available in the materializer.
        // </summary>
        // <param name="entity"> The entity to wrap </param>
        // <param name="relationshipManager"> The RelationshipManager associated with this entity </param>
        // <param name="entitySet"> The entity set, or null if none is known </param>
        // <param name="context"> The context to which the entity should be attached </param>
        // <param name="mergeOption"> NoTracking for non-tracked entities, AppendOnly otherwise </param>
        // <param name="identityType"> The type of the entity ignoring any possible proxy type </param>
        protected BaseEntityWrapper(
            TEntity entity, RelationshipManager relationshipManager, EntitySet entitySet, ObjectContext context, MergeOption mergeOption,
            Type identityType, bool overridesEquals)
        {
            Debug.Assert(!(entity is IEntityWrapper), "Object is an IEntityWrapper instance instead of the raw entity.");
            DebugCheck.NotNull(entity);

            if (relationshipManager == null)
            {
                throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull);
            }

            _identityType        = identityType;
            _relationshipManager = relationshipManager;

            if (overridesEquals)
            {
                _flags = WrapperFlags.OverridesEquals;
            }

            RelationshipManager.SetWrappedOwner(this, entity);

            if (entitySet != null)
            {
                Context     = context;
                MergeOption = mergeOption;
                RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
            }
        }
Ejemplo n.º 2
0
 // See IEntityWrapper documentation
 public void AttachContext(ObjectContext context, EntitySet entitySet, MergeOption mergeOption)
 {
     DebugCheck.NotNull(context);
     Context     = context;
     MergeOption = mergeOption;
     if (entitySet != null)
     {
         RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
     }
 }
Ejemplo n.º 3
0
 // See IEntityWrapper documentation
 public void AttachContext(ObjectContext context, EntitySet entitySet, MergeOption mergeOption)
 {
     Debug.Assert(null != context, "context");
     Context     = context;
     MergeOption = mergeOption;
     if (entitySet != null)
     {
         RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a wrapper as part of the materialization process.  This constructor is only used
 /// during materialization where it is known that the entity being wrapped is newly constructed.
 /// This means that some checks are not performed that might be needed when thw wrapper is
 /// created at other times, and information such as the identity type is passed in because
 /// it is readily available in the materializer.
 /// </summary>
 /// <param name="entity">The entity to wrap</param>
 /// <param name="relationshipManager">The RelationshipManager associated with this entity</param>
 /// <param name="entitySet">The entity set, or null if none is known</param>
 /// <param name="context">The context to which the entity should be attached</param>
 /// <param name="mergeOption">NoTracking for non-tracked entities, AppendOnly otherwise</param>
 /// <param name="identityType">The type of the entity ignoring any possible proxy type</param>
 protected BaseEntityWrapper(TEntity entity, RelationshipManager relationshipManager, EntitySet entitySet, ObjectContext context, MergeOption mergeOption, Type identityType)
 {
     Debug.Assert(!(entity is IEntityWrapper), "Object is an IEntityWrapper instance instead of the raw entity.");
     Debug.Assert(entity != null, "Factory should ensure wrapped entity here is never null.");
     if (relationshipManager == null)
     {
         throw EntityUtil.UnexpectedNullRelationshipManager();
     }
     _identityType        = identityType;
     _relationshipManager = relationshipManager;
     RelationshipManager.SetWrappedOwner(this, entity);
     if (entitySet != null)
     {
         Context     = context;
         MergeOption = mergeOption;
         RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
     }
 }