Skip to main content

IConnectionConfigProvider.GetConnectionConfigPath() Method

Returns the full path to the file that stores connection strings.

Namespace: DevExpress.Data.Entity

Assembly: DevExpress.Data.v24.1.dll

NuGet Package: DevExpress.Data

Declaration

string GetConnectionConfigPath()

Returns

Type Description
String

The full path to the file that stores connection strings

Remarks

The code sample below shows how to use IConnectionConfigProvider to provide a custom configuration file with connection strings. The sample assumes that you have an Entity Framework data model named NorthwindEntities that describes data fields. The code creates a new EFDataSource and assigns it as a data source for XtraReport1.

using DevExpress.Data.Entity;
using DevExpress.DataAccess.EntityFramework;
// ...
    class EFConnectionConfig : IConnectionConfigProvider, IConnectionStringsProvider {
        public IConnectionStringInfo[] GetConfigFileConnections() {
            throw new NotImplementedException();
        }

        public string GetConnectionConfigPath() {
            // Return the path to custom configuration file
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "efConnectionStrings.config"); ;
        }

        public IConnectionStringInfo[] GetConnections() {
            throw new NotImplementedException();
        }

        public string GetConnectionString(string connectionStringName) {
            throw new NotImplementedException();
        }

        public IConnectionStringInfo GetConnectionStringInfo(string connectionStringName) {
            throw new NotImplementedException();
        }
    }
    public class EFConnection {
        public void ConfigureDataSource() {

            // Create a report instance
            var xtraReport1 = new DevExpress.Examples.CoreLibraries.XtraReport();

            // Create an EFDataSource
            var dataSource = new EFDataSource();

            dataSource.ConnectionParameters = new EFConnectionParameters(typeof(NorthwindEntities));

            // Set the report's data source
            xtraReport1.DataSource = dataSource;

            xtraReport1.DataMember = "Products";

            var reportDesignTool = new ReportDesignTool(xtraReport1);

            // Register the interface as a service
            reportDesignTool.DesignForm.DesignMdiController.AddService(typeof(IConnectionStringsProvider), new EFConnectionConfig());

            reportDesignTool.ShowDesigner();

        }
    }
See Also