Adding an Index

  • Add a member of type Index
  • Add the Index columns in the constructor using the Add syntax
  • Determine if the Index is unique, using the Unique property
using System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box;
using ENV.Data;

namespace Northwind.Models
{
    public class Students : Entity
    {
        [PrimaryKey]
        public readonly NumberColumn Id = new NumberColumn("Id", "5"){ AllowNull = false };
        public readonly TextColumn LastName = new TextColumn("LastName", "30");
        public readonly TextColumn FirstName = new TextColumn("FirstName","30");
        public readonly Index SortById = new Index() { Unique = true };

        public Students()
            : base("Students", Northwind.Shared.DataSources.Northwind1)
        {
            SortById.Add(Id);
        }
    }
} 

Another index:

using System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box;
using ENV.Data;

namespace Northwind.Models
{
    public class Students : Entity
    {
        [PrimaryKey]
        public readonly NumberColumn Id = new NumberColumn("Id", "5"){ AllowNull = false };
        public readonly TextColumn LastName = new TextColumn("LastName", "30");
        public readonly TextColumn FirstName = new TextColumn("FirstName","30");
        public readonly Index SortById = new Index() { Unique = true };
        public readonly Index SortByName = new Index() { Unique = true };

        public Students()
            : base("Students", Northwind.Shared.DataSources.Northwind1)
        {
            SortById.Add(Id);

            SortByName.Add(LastName, FirstName, Id);
        }

    }
} 
  • Use the options, view by key menu entry to select the Index to use

Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com