567
Views
7
Comments
Mapping from C# object to structure
Question
Hi guys,

I'm developing an extension that imports a .NET Assembly that takes as request an ID, calls a service with said ID and responds with a customer. A customer is defined by a series of attributes (name, surname, age, etc...).

Right now I had to define a structure and an action to map the customer to the structure in integration studio.

I wanted to know if it's possible to directly map the customer's attributes from the C# code into a structure.

Best regards,
David
2018-03-08 20-43-12
Robert Chanphakeo
What do you mean by directly map?

You can copy from your c# class struct to an outsytems structure.

First you loop through your c# array list, then you copy the content into an outsystems structure record list and thats it. 

RCMyItemRecord rec = new RCMyItemRecord(null); //Create a new record
rec.ssSTMyItem.ssName = "your value goes here"; //assign record with value
ssSTMyItem.Append(rec); //copy the record to the outsystems structure


 
2022-05-19 09-39-13
David Sousa
Robert Chanphakeo wrote:
What do you mean by directly map?

You can copy from your c# class struct to an outsytems structure.

First you loop through your c# array list, then you copy the content into an outsystems structure record list and thats it. 

RCMyItemRecord rec = new RCMyItemRecord(null); //Create a new record
rec.ssSTMyItem.ssName = "your value goes here"; //assign record with value
ssSTMyItem.Append(rec); //copy the record to the outsystems structure


 
What I needed was to import a .NET assembly with a method returning a structure to be used in OutSystems.
I would prefer if I didn't have to add structures, actions or customize the generated code to make the mappings. 
Is it possible?
I think that in your solution you edit the source code to map the variables.


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Hi David,

This is not possible. A Platform record is a different beast than a simple structure. You'll need to convert whatever is returned by the external service / assembly to a Record or Record List in your extension.
2022-05-19 09-39-13
David Sousa
Kilian Hekhuis wrote:
Hi David,

This is not possible. A Platform record is a different beast than a simple structure. You'll need to convert whatever is returned by the external service / assembly to a Record or Record List in your extension.
 Hi Kilian,

Thanks for the quick answer, that was exactly what I wanted to confirm.
I thought that there was a way of generating structures when importing .net assemblies. That would be great!
 
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Well, importing a DLL is done in Visual Studio, which doesn't have any notion of the Platform. The only way would be to import DLLs directly with Integration Studio, but I don't see that happen, ever.
2022-05-19 09-39-13
David Sousa
But you can import DLL in integration studio, replicating the methods into actions.
If the input/output of a method is a complex type, it doesn't generate a structure and calls the parameter an Object. All the mappings from Outsystems record to said object have to be done in a custom action.
 
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Ah, I see, didn't know that. Yes, it would probably be nice if the Platform could do that automatically.
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.