A DataSet URI completely defines the source of data and its access mode. The DataSet URI has a schema named "msds".
The main identification string has the following syntax:
More formally, the URI format is:
::= parameters¶meters | parameter-name=parameter-value
The provider-identifier and the set of parameter-names depend on the particular DataSet provider. DataSet URI is case-sensitive.
Opening DataSet from URI
DataSet constructors accept a string that is either a file path or a correct URI—that is, a URI that has the correct provider name
and set of parameters. For instance, CsvDataSet
accepts the two following URIs:
However, the string "msds:nc?file=c:\data.test.csv" would cause an error because it specifies "nc" as the provider name instead of "csv".
The provider should have the DataSetProviderNameAttribute
specifying its name. The
associates extensions with the provider. For example:
public class CsvDataSet : DataSet
Every DataSet has the property DataSet.URI
, which returns a URI of the
Note to developers: The DataSetUri
class implements basic functionality for parsing and verifying DataSet URIs. You should use
this class to embed support for URIs into a DataSet provider. Some standard flags that often appear in Dataset URIs are
described below in the Standard parameters
The DataSet factory enables the creation of dataset instances by providing only a URI, without an explicit constructor call. For example:
DataSet dataSet = DataSet.Open("csv_for_autotypes.csv");
DataSet dataSet = DataSet.Open("msds:csv?file=csv_for_autotypes.csv");
DataSet dataSet = DataSet.Open(@"c:\data\ncfile.nc");
DataSet dataSet = DataSet.Open("msds:nc?file=ncfile.nc");
DataSet dataSet = DataSet.Open("msds:as?server=(local)&database=ActiveStorage" +
Before you can create instances the DataSet.Open
method, the provider must be registered in the factory. Installer automatically registers all the installed providers in the Machine.config file.
The factory control class is the static class Microsoft.Research.Science.Data.Factory.DataSetFactory
. The class allows you to register providers and create new instances. The class is used by the
There are several ways to register providers:
- DataSetFactory.Register group of methods.
- Add special section in application or machine configuration file.
These methods allow you to both register provider names and associate extensions with a particular provider. The methods use the previously mentioned attributes
in the process.
For example, the NetCDFDataSet
provider can be registered by using the DataSetFactory.Register methods in the following two ways:
The second way to register providers is the method DataSetFactory.SearchFolder
. This method accepts a path, searches in that folder for all assemblies that contain providers, and registers the providers that it finds. In the following example, the method
registers all the providers found in assemblies in the current directory:
method is intended mostly for developers and is marked with the DEBUG conditional compilation symbol. Release builds should rely on correct configuration files or manual provider registration.
Most providers accept these parameters. Note to developers: support of these flags is built-in to the class
The "openMode" flag specifies how the dataset should open a file, database, or whatever resource it uses to store the data.
Possible values for the flag are:
||Specifies that the data set should create a new resource. If the resource already exists, the exception IOException is thrown.
||Specifies that the data set should open an existing resource. If the resource does not exist, the exception ResourceNotFoundException is thrown.
||Specifies that the data set should create a new resource. If the resource already exists, it will be created again.
||Specifies that the data set should open an existing resource. If the resource does not exist, the dataset creates a new resource.
DataSet dataSet = DataSet.Open("msds:nc?file=data.nc&openMode=open");
DataSet dataSet = DataSet.Open("msds:as?server=(local)&database=ActiveStorage&" +