コード例 #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 the entity</param>
 /// <param name="key">The entity's key</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>
 /// <param name="propertyStrategy">A delegate to create the property accesor strategy object</param>
 /// <param name="changeTrackingStrategy">A delegate to create the change tracking strategy object</param>
 /// <param name="keyStrategy">A delegate to create the entity key strategy object</param>
 protected EntityWrapper(TEntity entity, RelationshipManager relationshipManager, EntityKey key, EntitySet set, ObjectContext context, MergeOption mergeOption, Type identityType,
                         Func <object, IPropertyAccessorStrategy> propertyStrategy, Func <object, IChangeTrackingStrategy> changeTrackingStrategy, Func <object, IEntityKeyStrategy> keyStrategy)
     : base(entity, relationshipManager, set, context, mergeOption, identityType)
 {
     if (relationshipManager == null)
     {
         throw EntityUtil.UnexpectedNullRelationshipManager();
     }
     _entity                 = entity;
     _propertyStrategy       = propertyStrategy(entity);
     _changeTrackingStrategy = changeTrackingStrategy(entity);
     _keyStrategy            = keyStrategy(entity);
     Debug.Assert(_changeTrackingStrategy != null, "Change tracking strategy cannot be null.");
     Debug.Assert(_keyStrategy != null, "Key strategy cannot be null.");
     _keyStrategy.SetEntityKey(key);
 }