Resources for IT Professionals > Forums Home > BizTalk Server Forums > BizTalk Server RFID > Business Rule Composer and use of RfidRuleEngineContext.GetVendorSpecificData
Ask a questionAsk a question
 

AnswerBusiness Rule Composer and use of RfidRuleEngineContext.GetVendorSpecificData

  • Wednesday, October 21, 2009 2:05 PMPABerg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi.

    In a RFID process I have a eventhandler and a BRE policy.
    In the policy a have some conditions testing for certain values in the VendorSpecificData.
    I get the VendorSpecificData by quering the database from a eventhandler:
    The query may be: select * from visitors where tagID='tagID'. Returning one row, and add that to the VendorSpecificData.
    tagReadEvent.VendorSpecificData.Add(key, value);

    Until now only one row has been returned, meaning that the VendorSpecificData only has one "row" inside.

    In the policy a condition can be like this:
    RfidRuleEngineContext.GetVendorSpecificData(Name) is equal to Boblehai

    So what if the query returns more than one row? Will there be performed an iteration in the policy? Or will it just look at the first "row".

    Regards
    Arthur

Answers

  • Sunday, October 25, 2009 4:40 PMKranthi Kumar M [MSFT] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Just to make sure I am answering the right question, here's the picture I got from your question:

    You have a custom BizTalk RFID Event-Handler component that you have written, and then a RuleEnginePolicyExecutor component in your RFID process. In your custom EH, you run a database query and add stuff to tagReadEvent.VendorSpecificData (as you've shown above). This is the query your are referring to when you say 'what if the query returns more than one row'.

    - At this point, I've got a question: what's the "key" you use? VendorSpecificData is a Dictionary<string, object>, so you obviously can't have multiple entries with the same key. If your query returns multiple rows from the db, and you need to add these to tagReadEvent.VendorSpecificData, you either need multiple keys for putting the entries in the dictionary (easier to use from the Business Rules Composer, from what I see), or, you need to have a single entry which is of the type Collection<your_data_type> (useful if the number of rows returned by the query keeps changing, but may be using it in the Rules Composer is a bit more difficult).

    If this doesn't answer your question, please provide more information on what the problem exactly is.

    HTH,
    Kranthi.

All Replies

  • Sunday, October 25, 2009 4:40 PMKranthi Kumar M [MSFT] Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Just to make sure I am answering the right question, here's the picture I got from your question:

    You have a custom BizTalk RFID Event-Handler component that you have written, and then a RuleEnginePolicyExecutor component in your RFID process. In your custom EH, you run a database query and add stuff to tagReadEvent.VendorSpecificData (as you've shown above). This is the query your are referring to when you say 'what if the query returns more than one row'.

    - At this point, I've got a question: what's the "key" you use? VendorSpecificData is a Dictionary<string, object>, so you obviously can't have multiple entries with the same key. If your query returns multiple rows from the db, and you need to add these to tagReadEvent.VendorSpecificData, you either need multiple keys for putting the entries in the dictionary (easier to use from the Business Rules Composer, from what I see), or, you need to have a single entry which is of the type Collection<your_data_type> (useful if the number of rows returned by the query keeps changing, but may be using it in the Rules Composer is a bit more difficult).

    If this doesn't answer your question, please provide more information on what the problem exactly is.

    HTH,
    Kranthi.
  • Wednesday, October 28, 2009 9:03 AMPABerg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi.

    Thanks for your reply. Yes you answered the right question.

    But what about using database facts as conditions. Can that result in getting more than one row? For example:

    IF
    Conditions
    AND
    MyDatabase.Table.value is equal to 5

    THEN
    Actions
    MyDatabase.Table.value=6

    What if my table has several rows with value 5. Will all of them getting updated?

    Regards
    Arthur