IDC Documentation Home

Typical usage of the IDC involves mapping a table in the database against a class in your application. This is achieved by extending a class off the base "Table" class in the IDC. Additionally, a class must be defined to store individual row (or record) data, this class must extend from the base "DataRecord" class in the IDC. The record class is then passed as a generic to the table class, so it can automatically be used to store data. Within the record class, properties are matched to fields in the database by either matching the name exactly, or by using the “ColumnName” attribute to set the source column name manually. Data types are important as well, and the .NET type must align with the SQL type.

All fields in the database must be included in the record object, or mapping errors will occur when attempting to interact with the database. There are options to exclude columns when reading data, if you only want to load a subset of your column data.

using System;
using System.Collections.Generic;
using System.Linq;
using Infotekka.DataConnection;
using Infotekka.DataConnection.Attributes;

namespace IdcDemo.Models.TestDB
{
    public class People : Table<People.Record>
    {
        protected override string ConnectionString => Configuration.ConnectionString;

        public class Record : DataRecord
        {
            [Identity]
            [ColumnName("ID")]
            public int Id { get; set; }

            [ColumnLength(255)]
            public string Name { get; set; } = "";

            public DateTime DateOfBirth { get; set; }

            [ColumnName("PHONE")]
            [ColumnLength(20)]
            public string Phone { get; set; }

            [ColumnName("Favorite_COLOR")]
            public string FavoriteColor { get; set; }
        }
    }
}
Get the Latest Version
Documentation and Support

The Infotekka Data Connection is free for download and use without modification, however the source code remains the proprietary property of Infotekka, LLC.