Added new functions and helpers to help create tables and set them up. Bumped package version to 1.0.3

This commit is contained in:
2023-01-31 13:03:17 -08:00
parent 70dd86766b
commit 287cb2d43d
10 changed files with 466 additions and 98 deletions

View File

@ -8,19 +8,19 @@ namespace MontoyaTech.MySqlPlus.Example
[MySqlRow("cars")]
public class Car
{
[MySqlColumn(Id = true, Name = "id")]
[MySqlColumn(Id = true, Name = "id", PrimaryKey = true, AutoIncrement = true, Nullable = false)]
public ulong Id = 0;
[MySqlColumn("make")]
public string Make = null;
[MySqlColumn("model")]
public string Model = null;
[MySqlColumn("model", Nullable = false, Type = "VARCHAR(255)")]
public string Model = "Unknown";
[MySqlColumn("year")]
[MySqlColumn("year", Nullable = false)]
public uint Year = 0;
[MySqlColumn("dateCreated", typeof(DateTimeToUnixConverter))]
[MySqlColumn("dateCreated", typeof(DateTimeToUnixConverter), DefaultValue = 0, Nullable = false)]
public DateTime DateCreated = DateTime.UtcNow;
}
@ -28,6 +28,8 @@ namespace MontoyaTech.MySqlPlus.Example
{
var session = new MySqlSession("");
session.CreateTable<Car>();
session.DeleteAll<Car>();
session.Insert(new Car() { Make = "Chevy", Model = "Camaro", Year = 2011 });
@ -46,6 +48,8 @@ namespace MontoyaTech.MySqlPlus.Example
foreach (var car in cars)
session.Delete(car);
session.DeleteTable<Car>();
Console.WriteLine("Done.");
Console.ReadLine();
}