/EasyMySql.net

Simple ERM framework for .net and Mysql

Primary LanguageC#MIT LicenseMIT

EasyMySql.net

Simple ERM framework for .net and Mysql

##Usage

Step 1:

Set the MySql Connection string:

 Settings.ConnectionString = "Server=YOURSERVER;Database=YourDB;Uid=USER;Pwd=PASSWORD";

Step 2:

Create a class that inherits the DataObject And decorate it with the Ignore, Unique and/or Length attributes

public class MysqlObject : DataObject
{
    public int IntValue { get; set; }
    public double DoubleValue { get; set; }
    public bool BoolValue { get; set; }
    [Length(100)]
    public string StringValue { get; set; }
    public DateTime DateTimeValue { get; set; }
    [Ignore]
    public bool IgnoredValue { get; set; }
    [Length(250)]
    public string LongerString { get; set; }
	[Unique]
	public int UniqueValue { get; set; }
}

Step 3:

Spawn a new DataHandler class

var handler = new DataHandler<MysqlObject>()

or create a new handler class to get access to more functionality and/or Caching

public class MysqlObjectHandler : DataHandler<MysqlObject>
{
    public static readonly MysqlObjectHandler Instance = new MysqlObjectHandler();

    private MysqlObjectHandler()
    {

    }
}

Step 4:

Add or retrieve data with the DataHandler

MysqlObjectHandler.instance.Add(new MysqlObject() { BoolValue = true, DateTimeValue = DateTime.Now, DoubleValue = 0.1, IgnoredValue = true, IntValue = 32, StringValue = "Teststring", UniqueValue = 2 });

var Result = MysqlObjectHandler.instance.GetItems();

var Result = new DataHandler<MysqlObject>().GetItems();