Skip to main content
Home  ›  Blog

Custom DataSource API - VisualQuery Attribute

To help the Visual Query Designer properly guide the user, there is an C# Attribute called VisualQuery to configure everything.

This is part of the new API for DataSources released in 2sxc 9.13.

How to use VisualQuery

Here's a simple example of the FormAndList DataSource:

Using the VisualQuery in FormAndList

[VisualQuery(
    GlobalName = "0a0924a5-ca2f-4db5-8fc7-1a21fdbb2fbb",
    NiceName = "Dnn FormAndList",
    Type = DataSourceType.Source, 
    ExpectsDataOfType = "d98db323-7c33-4f2a-b173-ef91c0875124",
    HelpLink = "https://github.com/2sic/dnn-datasource-form-and-list/wiki")]

This example shows how the the FormAndList DataSource tells the UI things like:

  1. the global name
  2. that it's a source (and not a filter) - affecting the icon shown
  3. that it has a content-type which should be used for the UI to configure it
  4. the help-link in the UI

What you can Configure on VisualQuery

These are the things you can configure:

  1. string GlobalName - required this should be a unique id, ideally a GUID
    important: old code use string names like a .net namespace. This should not be done any more and will be deprecated in the future
  2. DataSourceType Type - a type which basically controlls the icon shown in the designer. Supported values are
    1. Cache
    2. Filter
    3. Logic
    4. Lookup
    5. Modify
    6. Security
    7. Sort
    8. Source
    9. Target
  3. string ExpectsDataOfType - if your datasource expects configuration, use this to tell the UI which content-type should be opened. Should be a GUID.
    important: old code sometimes uses string-names. This will be deprecated in the future, so use GUIDs only
  4. string[] In - optional information if your source expects multiple in-sources (default is empty)
  5. string HelpLink - a url to a page giving the user help on this DataSource
  6. string NiceName - a nicer name to show in the UI instead of the GlobalName

Advanced Stuff

For advanced details, read the wiki about the VisualQuery attribute.

Love from Switzerland,
Daniel


Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler