Skip to content

Get actual values from .ToDictionary() #242

Answered by fw2568
kambalin asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
as you can see in your screenshot the type of field ID is actually a AbapStringValue. So you can cast the property to access the value:

var id = ((AbapStringValue) r["ID"]).Value;

This solution should be sufficient in almost all cases when you know the property type of the field.

Another - more generic approach is to use the FieldMapper of IRfcRuntime:

  IRfcRuntime rfcRuntime;  // get this from dependency injection
  rfcRuntime.FieldMapper.FromAbapValue<string>(dictionary["ID"]).Match(
      id =>
      {
          // do something with the value
      },
      (left) =>
      {
          // handle error
      }
  );

Access to IRfcRuntime is possible via IConnection or directly from d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kambalin
Comment options

Answer selected by kambalin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants