C# usage in the OData connector

Under construction

Overview

There are cases when either standard projection operation is missing from specifications (even though the operation exists according to Chrome inspect log) or it just won’t work, one example is when an entity uses an enum as part of it’s key. There is a bug in Microsoft OData Client which prevents that from working.

It does not matter under which Projection you select the Code section to create the C# code.

When opening the code section of first time it looks something like this

In the left part you can see the entity sets available and your own defined classes.

Your code is written in the middle part of the UI. It has some syntax coloring, but other than that, it does not provide much assistance.

The right part, “Flow”, contains whatever variables are available from Flow.

Generated methods signature

First line in the code section is so called signature (= method name and the type) which is automatically generated and cannot be manually modified. It contents will however change automatically based on what you return from the call to flow.

public async System.Threading.Tasks.Task<string> ODataOperation(ODataSource container, FlowVariables flowVariables, System.Net.Http.HttpClient httpClient, System.Threading.CancellationToken token)

Method returns a Task of something (string in the example above) and takes four parameters:

  • container – a reference to the OData container, a class deriving from DataServiceContext Class (Microsoft.OData.Client) | Microsoft Docs This document does not focus on this feature.

  • flowVariables – a reference to the available flow variables that can be used in the code. Example “flowVariables.userId”,

  • httpClient, an already prepared httpClient (with regard to logging, auth and so forth) that you can use to send requests to the OData endpoint. This is the focus of this document, we’ll return to it shortly and

  • cancellation token where you can (and should) provide whenever you are executing asynchronous operations in your code.

Last updated