Defining Input Data Schema

Describes how users define the input data schema

1. Add input schema file

In the MyInputs folder in your solution, right-click and select "Add (D)" > "Add New Item (W)...". Select the InputData item from the list of items, name it [schema name].cs, and press the "Add (A)" button to add it. The example below shows the screen for adding an input schema named "SampleData".

2. Define input schema and KeyMappings

Define column names and data types in the added input schema file. There is no limit to the number of columns you can define and you are free to add as many as you need. The example below defines two columns "COL_1", "COL_2" of type String.

You can add KeyMappings as needed to look up data through defined keys. KeyMappings can be added through the constructor of the schema file. The example code below creates a KeyMappings with "COL_1" as the Key and another with "COL1" and "COL_2" as the Key. KeyMappings are Dictionary structures with Int as a key, and you can access each KeyMapping through the Key of the KeyMappings. You can see how to retrieve data through KeyMappings here.

using Nodez.Data;
using Nodez.Data.Interface;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Nodez.Project.Template.MyInputs
{
    public class SampleData : IInputRow
    {
        // Define columns here (NOTICE: The column name defined here and the column name defined in the data file must match.)

        public string COL_1 { get; private set; }

        public string COL_2 { get; private set; }

        public SampleData()
        {
            // Define keys here (You can search data with the key defined here. Allow multiple keys)

            HashSet<string> key = new HashSet<string>();
            key.Add("COL_1");

            this.KeyMappings.Add(1, key);

            HashSet<string> key2 = new HashSet<string>();
            key2.Add("COL_1");
            key2.Add("COL_2");

            this.KeyMappings.Add(2, key);
        }
    }
}

The column names defined in the input schema file must match the column names defined in the input data file. We recommend that you also define the data type for each column defined in the input schema file to match what is defined in the input data file.

Last updated