Skip to main content
A newer version of this page is available. .

IJsonDataConnectionProviderService.GetJsonDataConnection(String) Method

Gets a connection by name.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v20.2.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.WindowsDesktop.DataAccess

Declaration

JsonDataConnection GetJsonDataConnection(
    string name
)

Parameters

Name Type Description
name String

A connection name.

Returns

Type Description
JsonDataConnection

A JSON connection.

Remarks

The GetJsonDataConnection method resolves a connection name to a JSON connection.

The following code retrieves a connection string from the dictionary for the given connection name, and creates and returns the JsonDataConnection object.

using DevExpress.DataAccess.Json;
using DevExpress.DataAccess.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
...
    public class WebDocumentViewerJsonDataConnectionProvider : IJsonDataConnectionProviderService
    {
        readonly Dictionary<string, string> jsonDataConnections;
        public WebDocumentViewerJsonDataConnectionProvider(Dictionary<string, string> jsonDataConnections)
        {
            this.jsonDataConnections = jsonDataConnections;
        }
        public JsonDataConnection GetJsonDataConnection(string name)
        {
            if (jsonDataConnections == null)
                return null;
            return CustomDataSourceWizardJsonDataConnectionStorage.CreateJsonDataConnectionFromString(
                name, jsonDataConnections[name]);
        }
    }

For more information and code examples, review the following help topic: JSON Data - Register Connections.

See Also