All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

MongoDBDataSourceBase.Fill(String[]) Method

Executes the specified queries and loads data from a MongoDB instance.

Namespace: DevExpress.DataAccess.MongoDB

Assembly: DevExpress.DataAccess.v21.1.dll

Declaration

public void Fill(
    string[] queriesToFill
)

Parameters

Name Type Description
queriesToFill String[]

An array of query names. A Fill method call executes queries with these names.

Remarks

A MongoDB data source stores a collection of queries to database collections of a MongoDB instance. Call the Fill method to execute these queries and load data from the MongoDB instance to the data source. You can also call the FillAsync() method to load data asynchronously.

Example

The example below demonstrates how to use the MongoDBDataSource class to bind an application or component to a MongoDB instance. The example uses the MongoDBCustomConnectionParameters class to specify a connection string to the MongoDB instance and the MongoDBQuery class to specify data queries to the Categories and Products collections of the Northwind database. The example shows how to use the Fill(String[]) method to execute individual queries.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.MongoDB;
using DevExpress.DataAccess;
using DevExpress.DataAccess.ObjectBinding;
// ...
// Create an object to store a connection string to a MongoDB instance.
var connectionParameters = new MongoDBCustomConnectionParameters() {
    ConnectionString = "mongodb://localhost:27017"
};

// Specify queries to database collections.
var queryCategories = new MongoDBQuery() {
    DatabaseName = "Northwind",
    CollectionName = "Categories",
};

var queryProducts = new MongoDBQuery() {
    DatabaseName = "Northwind",
    CollectionName = "Products",
};

// Create a MongoDBDataSource object. Assign the created connection
// string and queries to the object's ConnectionParameters and
// Queries properties.
var mongoDBDataSource = new MongoDBDataSource() {
    ConnectionParameters = connectionParameters,
    Queries = { queryProducts, queryCategories },
};

// Specify an array of query names. The queries with these name are executed
// after the Fill method is called.
var queriesToFill = new[] { "Products" };

// Call the Fill method of the MongoDBDataSource object to execute queries
// and load data from the MongoDB instance. Pass the array of query names to
// this method.
mongoDBDataSource.Fill(queriesToFill);

// Use the created object as a data source in your application/component.
//...
See Also