/// <summary> /// Constructs a wrapper for the given entity. /// Note: use EntityWrapperFactory instead of calling this constructor directly. /// </summary> /// <param name="entity">The entity to wrap</param> /// <param name="relationshipManager">The RelationshipManager associated with the entity</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, Func <object, IPropertyAccessorStrategy> propertyStrategy, Func <object, IChangeTrackingStrategy> changeTrackingStrategy, Func <object, IEntityKeyStrategy> keyStrategy) : base(entity, relationshipManager) { 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."); }
/// <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); }
// <summary> // Constructs a wrapper for the given entity. // Note: use EntityWrapperFactory instead of calling this constructor directly. // </summary> // <param name="entity"> The entity to wrap </param> // <param name="relationshipManager"> The RelationshipManager associated with the entity </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, Func <object, IPropertyAccessorStrategy> propertyStrategy, Func <object, IChangeTrackingStrategy> changeTrackingStrategy, Func <object, IEntityKeyStrategy> keyStrategy, bool overridesEquals) : base(entity, relationshipManager, overridesEquals) { if (relationshipManager == null) { throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull); } _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."); }
protected EntityWrapper( TEntity entity, RelationshipManager relationshipManager, Func <object, IPropertyAccessorStrategy> propertyStrategy, Func <object, IChangeTrackingStrategy> changeTrackingStrategy, Func <object, IEntityKeyStrategy> keyStrategy, bool overridesEquals) : base(entity, relationshipManager, overridesEquals) { if (relationshipManager == null) { throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull); } this._entity = entity; this._propertyStrategy = propertyStrategy((object)entity); this._changeTrackingStrategy = changeTrackingStrategy((object)entity); this._keyStrategy = keyStrategy((object)entity); }
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, bool overridesEquals) : base(entity, relationshipManager, set, context, mergeOption, identityType, overridesEquals) { if (relationshipManager == null) { throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull); } this._entity = entity; this._propertyStrategy = propertyStrategy((object)entity); this._changeTrackingStrategy = changeTrackingStrategy((object)entity); this._keyStrategy = keyStrategy((object)entity); this._keyStrategy.SetEntityKey(key); }