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:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user