Since a virtual table doesn't really exist, Stonefield Query can't send a SQL statement to the database engine to retrieve the data for it. Instead, you have to write a plugin to create the result set for the virtual table.

A virtual table plugin implements the IStonefieldQueryVirtualTablePlugin interface in Interfaces.dll and uses the StonefieldQueryVirtualTablePlugin attribute. Your plugin needs references to the Collections, Enums, Interfaces, PluginManager, and System.ComponentModel.Composition assemblies (the first four are Stonefield Query assemblies and the latter is a .NET assembly). It may also need references to other Stonefield Query assemblies, depending on what the plugin does; these can be found in the SQWeb\bin folder.

Studio can generate the source code for a plugin for you; see the Generating Plugin Source Code topic for details.

IStonefieldQueryVirtualTablePlugin

Here's the definition of IStonefieldQueryVirtualTablePlugin:

using System;
using System.Data;
using Stonefield.Query.ConnectionManagement;
using Stonefield.Query.ReportEngine;
using System.Collections.Generic;
using Stonefield.Query.DataDictionary;
 
namespace Stonefield.Query.Plugins
{
    /// <summary>
    /// The interface that VirtualTable plugins must implement.
    /// </summary>
    /// <remarks>
    /// Plugin classes implementing this interface must have an
    /// attribute that implements
    /// IStonefieldQueryVirtualTablePluginMetaData.
    /// </remarks>
    public interface IStonefieldQueryVirtualTablePlugin :
        IStonefieldQueryBasePlugin
    {
        /// <summary>
        /// Returns a list of parameters the Select method needs
        /// (typically when it calls a stored procedure).
        /// </summary>
        /// <param name="table">
        /// A reference to the table the plugin is for.
        /// </param>
        /// <returns>
        /// A list of IParameters.
        /// </returns>
        List<IParameter> GetParameters(ITable table);

        /// <summary>
        /// Retrieves the data for the virtual table and returns a
        /// DataTable.
        /// </summary>
        /// <param name="connection">
        /// A connection object to use for the data retrieval.
        /// </param>
        /// <param name="datasource">
        /// The name of the datasource being connected to.
        /// </param>
        /// <param name="select">
        /// A SQL statement that retrieves the fields needed for the
        /// report.
        /// </param>
        /// <param name="tablename">
        /// The name of the table.
        /// </param>
        /// <param name="report">
        /// The report the result is for.
        /// </param>
        /// <param name="table">
        /// A reference to the table the plugin is for.
        /// </param>
        /// <returns>
        /// A DataTable containing the data.
        /// </returns>
        DataTable Select(IConnection connection, string datasource,
            string select, string tablename, IReport report, 
            ITable table);
    }
}

(As with all plugins that derive from IStonefieldQueryBasePlugin, it also has an Application member; see the Plugins topic for information about Application.)

StonefieldQueryVirtualTablePlugin

The StonefieldQueryVirtualTablePlugin attribute on the plugin class has the following parameters (see the Plugins topic for details on all but the last parameter):

  • The ID for the plugin.

  • The name of the plugin.

  • The type of plugin.

  • The name of the virtual table this is a plugin for.

Here's an example:

[StonefieldQueryVirtualTablePlugin("{FC5CDC44-72E7-415F-87F3-CEFB088FF4FE}",
    "SampleVirtualTablePlugin",
    PluginSource.Custom,
    "SampleVirtualTable",
    Version = "1.0.0.0",
    ExecutionPriority = 5)]
public class SampleVirtualTablePlugin :
    IStonefieldQueryVirtualTablePlugin

Plugin methods

Virtual table plugins have the following methods:

See Also

Plugins