The following is a quick explanation for how to create a Data Object using the Exago .NET Api.
First, ensure that your application is referencing the Entity class, which is located in the WebReports.Api.Reports namespace, and the DataSource class, which is located in the WebReports.Api.Data namespace.
NOTE: Not to be confused with the DataObject class.
using WebReports.Api.Reports;
using WebReports.Api.Data;
/* Manually Creating a Data Object */
Entity myEntity = myApi.Entities.NewEntity();
DataSource myDataSource = myApi.DataSources.GetDataSource("Northwind");
myEntity.DataSourceId = myDataSource.Id;
myEntity.ObjectType = DataObjectType.Table;
myEntity.DbName = "Products";
myEntity.Name = "Products";
myEntity.Id = "Products_0";
myEntity.KeyColumns.Add(myEntity.DbName, "ProductID");
NOTE: Data Objects created in the API are unique to their session.
First, create a new Entity using the following convenience method:
myApi.Entities.NewEntity();
Retrieve the Data Source, and set the Entity's DataSourceId:
myApi.DataSources.GetDataSource("DataSourceName"); - Returns a DataSource object.
myEntity.DataSourceId - Accepts the integer id property of a data source object.
Set the Entity to the type of Data Object (i.e. Table, View, Stored Procedure, etc.)
myEntity.ObjectType - Accepts a DataObjectType enumerator.
Then, set the Entity to the corresponding data object from the database:
myEntity.DbName - The name of the data object as it appears in the database.
NOTE: Don't append a Schema prefix (such as dbo) to the data object name. Set the myEntity.Schema property instead.
Give the entity a Name ("Alias") and an Id (if necessary).
myEntity.Name - A user-friendly name for the data object, to be seen in the report designer.
myEntity.Id - An identifier for the data object, in case multiple DbNames overlap. This field is optional.
Exago uses both the Name and Id fields to generate a unique identifier, a.k.a. mnemonic, for an entity. To retrieve an entity's mnemonic, use the following method:
myApi.Entities.GetMnemonicFromId(myEntity.DbName);
Finally, set the entity's unique key column(s):
myEntity.KeyColumns.Add(myEntity.DbName, "ProductID");