ExpressionEvaluator.EvalInContext Method (PIA)

Use this method to evaluate an expression against a pre-established context stored in the context cache.

Definition

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Targeting
…
Public Function EvalInContext(nExprID As Integer,
 pContext As Object) As Object

[C#]

using Microsoft.CommerceServer.Interop.Targeting;
…
public object EvalInContext(intnExprID,
 IExprEvalContextpContext);

Parameters

[Visual Basic .NET]

  • nExprID
    An Integer that contains the unique identification of the expression in the expression store.
  • pContext
    An ExprEvalContext object that identifies the specific context for this evaluation.

[C#]

  • nExprID
    An int that contains the unique identification of the expression in the expression store.
  • pContext
    An IExprEvalContext interface of an ExprEvalContext object that identifies the specific context for this evaluation.

Return Values

This method returns an Object indicating the result of the expression evaluated in the specified context. This result may be True, False, or Null. Null indicates that the expression could not be evaluated.

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

[Visual Basic .NET]

The following table shows the custom COM errors that a COMException can wrap.

Value Description
&H8110001F Invalid connection
&H8110000A Invalid expression ID specified
&H8110000D No connection string specified
&H8110001D Invalid ExprEvalContext object
&H81100012 Could not find the specified expression ID, nExprID, in the expression store

[C#]

The following table shows the custom COM errors, and the standard COM errors with special meanings, that COMException can wrap.

Value Description
0x8110001F Invalid connection
0x8110000A Invalid expression ID specified
0x8110000D No connection string specified
0x8110001D Invalid ExprEvalContext object
0x81100012 Could not find the specified expression ID, nExprID, in the expression store

Remarks

The Eval method creates and discards an evaluation context for every evaluation. Evaluating against a stored context optimizes performance when multiple expressions need to be evaluated in the same context. Create the context for evaluation using the CreateEvalContext method.

Expression results are also stored in the context cache. If the result of a particular expression is requested multiple times from the same ExprEvalContext object using the EvalInContext method, the result is retrieved from the cache rather than by re-evaluating the expression, further increasing efficiency.

Ee823372.caution(en-US,CS.20).gif Caution

  • The state of the profile objects that comprise the context should not be externally changed during the lifetime of the ExprEvalContext object; doing so leads to nondeterministic evaluation results.

The Connect method must be called before using the EvalInContext method.

[Visual Basic .NET]

Example

' oEvalContext is an ExprEvalContext object
' oResult is an Object
oResult = oExpressionEval.Eval(2134, oEvalContext)

Requirements

Namespace: Microsoft.CommerceServer.Interop.Targeting

Platforms: Windows 2000, Windows Server 2003

Assembly: exprarchlib (in exprarchlib.dll)

See Also

ExpressionEvaluatorClass

ExpressionEvaluator.Connect

ExpressionEvaluator.CreateEvalContext

ExpressionEvaluator.Eval

ExpressionEvaluator.LoadExpr

Copyright © 2005 Microsoft Corporation.
All rights reserved.