Skip to content

Instantly share code, notes, and snippets.

Avatar
Expecto Patronum!

Nishan Chathuranga Wickramarathna nishanc

Expecto Patronum!
View GitHub Profile
View Results
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
| TPH | 132.3 ms | 2.29 ms | 2.03 ms | 8000.0000 | 3000.0000 | 1250.0000 | 44.49 MB |
| TPT | 201.3 ms | 3.32 ms | 3.10 ms | 9000.0000 | 4000.0000 | - | 61.84 MB |
+--------+----------+---------+---------+-----------+-----------+-----------+-----------+
View Script.sql
CREATE TABLE [TPHUsers] (
[Id] int NOT NULL IDENTITY,
[Username] nvarchar(max) NULL,
[Email] nvarchar(max) NULL,
[UserType] nvarchar(max) NOT NULL,
[CGPA] nvarchar(max) NULL,
[Major] nvarchar(max) NULL,
[Designation] nvarchar(max) NULL,
[Speciality] nvarchar(max) NULL,
CONSTRAINT [PK_TPHUsers] PRIMARY KEY ([Id])
View Migration.cs
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TPCStudents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CGPA = table.Column<string>(type: "nvarchar(max)", nullable: true),
Major = table.Column<string>(type: "nvarchar(max)", nullable: true),
View Script.sql
CREATE TABLE [TPCStudents] (
[Id] int NOT NULL IDENTITY,
[CGPA] nvarchar(max) NULL,
[Major] nvarchar(max) NULL,
[Username] nvarchar(max) NOT NULL,
[Email] nvarchar(max) NOT NULL,
CONSTRAINT [PK_TPCStudents] PRIMARY KEY ([Id])
);
CREATE TABLE [TPCTeachers] (
View Models.cs
using System.ComponentModel.DataAnnotations;
public abstract class TPCUser
{
[Key]
public int Id { get; set; }
[Required]
public string Username { get; set; }
[Required]
public string Email { get; set; }
View Migration.cs
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TPTUsers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Username = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true)
View Script.sql
CREATE TABLE [TPTUsers] (
[Id] int NOT NULL IDENTITY,
[Username] nvarchar(max) NULL,
[Email] nvarchar(max) NULL,
CONSTRAINT [PK_TPTUsers] PRIMARY KEY ([Id])
);
GO
CREATE TABLE [TPTStudents] (
[Id] int NOT NULL,
View Models.cs
using System.ComponentModel.DataAnnotations.Schema;
[Table("TPTUsers")]
public class TPTUser
{
public int Id { get; set; }
public string Username { get; set; }
public string Email { get; set; }
}
View Models.cs
public class TPHUser
{
public int Id { get; set; }
public string Username { get; set; }
public string Email { get; set; }
public string UserType { get; set; }
}
public class TPHTeacher : TPHUser
{
View Migration.cs
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TPHUsers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Username = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),