ExpressionEvaluator.Eval Method (PIA)

Use this method to evaluate an expression.

Definition

[Visual Basic .NET]

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

[C#]

using Microsoft.CommerceServer.Interop.Targeting;
using Microsoft.CommerceServer.Interop;      //For IDictionary
…
public object Eval(intnExprID,
 IDictionarypDictObjs);

Parameters

[Visual Basic .NET]

  • nExprID
    An Integer that contains the unique identifier for the expression in the expression store.
  • pDictObjs
    A Dictionary object that contains a set of profiles.

[C#]

  • nExprID
    An int that contains the unique identifier for the expression in the expression store.
  • pDictObjs
    The IDictionary interface of a Dictionary object that contains a set of profiles.

Return Values

[Visual Basic .NET] This method returns an Object indicating the result of evaluating the expression in the specified context. The result may be True, False, or Null. Null indicates that the expression could not be evaluated.

[C#] This method returns an object indicating the result of evaluating the expression in the given context.

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
&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
0x81100012 Could not find the specified expression ID, nExprID, in the expression store

Remarks

Expressions must be precompiled and loaded into the expression cache before being evaluated. The Eval method first checks the expression cache for the expression, and if it is not found, loads the expression from the expression store. Use the LoadExpr or LoadAll method to preload an expression into the expression cache and improve evaluation performance.

An expression is evaluated against data contained in a set of profiles. This set of profiles is referred to as an evaluation context. A new evaluation context is generated by the Eval method using the Dictionary object. The Eval method discards the new context after completing the evaluation. This process is not efficient if many expressions must be evaluated against the same context.

If an evaluation context will be used across multiple expressions, create a context in the context cache using the CreateEvalContext method. Use the EvalInContext method to evaluate expressions in this new common context.

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

[Visual Basic .NET]

Example

' dictUser1, dictAddress1, & dictProfiles are Dictionary objects
' create 2 profiles
dictUser1.firstName = "Joe"
dictUser1.lastName = "User"
dictAddress1.city = "Somewhere"
dictAddress1.state = "WA"

' add the profiles to the context Dictionary
dictProfiles.User = dictUser1
dictProfiles.Address = dictAddress1

' evaluate the expression, vResult is an Object
oResult = oExpressionEval.Eval(2134, dictProfiles)

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.EvalInContext

ExpressionEvaluator.LoadExpr

Copyright © 2005 Microsoft Corporation.
All rights reserved.