When defining MagnaDB Table/View Models there a few things to take into consideration.
using System;
using MagnaDB.SqlServer;
namespace TestMagnaDB
{
public class Student : TableModel<Student>
{
protected override string ConnectionString => "Data Source=(local);Initial Catalog=testmagnadb;Integrated Security=True;";
protected override string TableName => "Students";
protected override MagnaKey Key => this.MakeKey(s => s.EnrollmentId);
public string EnrollmentId { get; set; }
[Identity]
public int SystemId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime EnrollmentDate { get; set; }
// This property can accept null values
public DateTime? GraduatedOn { get; set; }
// This is a quick example of enum properties
public AcademicStatus Status { get; set; }
// Let's say that null values represent that the student is not from a foreign country.
public MigratoryStatus? MigratorySituation { get; set; }
}
// Since this enum's underlying type is byte, in SQL Server
// it's matching type will be tinyint (this varies across DB engines)
public enum AcademicStatus : byte
{
Enrolled,
HasScholarship,
Graduated,
}
// Enums' underlying type is int by default, so it's matching type
// will be int for SQL Server (this varies across DB engines)
public enum MigratoryStatus
{
Resident,
Visa
}
}