DataConnector
ADO.NET provider for OData / Creating Connection
In This Topic
    Creating Connection
    In This Topic

    To create a connection in ADO.NET Provider, you can use C1ODataConnection class which implements a connection string passed as an argument. Another way to connect with the data source is using the C1ODataConnectionStringBuilder class which builds and parses connection strings through program code.

    The C1ODataConnectionStringBuilder class can also be used to setup the connection strings to be implemented by the provider for connecting to the datasource.

    Below code example shows how C1OdataConnectionStringBuilder class can be used to configure the connection string for OData and consumed by C1ODataConnection class to create a connection to OData server. You can query the data or request for modifications.

    //ODATA service URL
    const string NorthwindSampleUrl = @"https://services.odata.org/V4/Northwind/Northwind.svc";
    //Configure connection string         
    C1ODataConnectionStringBuilder builder = new C1ODataConnectionStringBuilder();         
    builder.Url = NorthwindSampleUrl;
    builder.Pooling = true;
               
    //Setup Connection
    C1ODataConnection con = new C1ODataConnection(builder.ConnectionString);
    
    Note: The properties of C1OdataConnectionStringBuilder can be used to setup the connection keys when passed as connection strings. The connection key will be the corresponding property with added space character. For example, "UseCache" will be used as "Use Cache".