Quickstart - Vidarls/Simple.Data.Mysql GitHub Wiki
#Quickstart This is just a quick code example on using the Simple.Data framework against a MySql database.
For more info and samples:
- The main Simple.Data Wiki
- Simple.Data.Sample, a sample demonstrating the simple.data features (also available on nuget)
- Nerdbeers, a demo project for NancyFx web framework and Simple.Data combined.
Now to the MySql Sample:
- Create a new console application
- Add Simple.Data.Mysql using Nuget
- Use Database.OpenConnection("Connectionstring") with the appropriate connection string to your MySql database.
- You are now ready to interact with your MySql database
using System;
using Simple.Data;
namespace SimpleDataDemo
{
class Program
{
static void Main(string[] args)
{
var db = Database.OpenConnection
("server=localhost;user=SimpleData;database=SimpleDataTest;password=test;");
var users = db.users.All();
foreach (var user in users)
{
Console.WriteLine(user.Name);
}
Console.ReadLine();
}
}
}