-
Notifications
You must be signed in to change notification settings - Fork 19
Quickstart
Vidarls edited this page Mar 26, 2011
·
3 revisions
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: http://github.com/markrendle/Simple.Data/wiki
- Simple.Data.Sample, a sample demonstrating the simple.data features http://github.com/markrendle/Simple.Data.Sample (also available on nuget http://nuget.org/List/Packages/Simple.Data.Sample.)
- Nerdbeers, a demo project for NancyFx web framework
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();
}
}
}