Quickstart guide - MichaelAz/TINA-ORM GitHub Wiki
So you want to use TINA-ORM? Cooleo.
We currently support Microsoft SQL Server and MySQL so you better get one of those set up. Once you're done with that, download the appropriate NuGet package for your database (Microsoft SQL Server, MySQL).
Hey, do you use a database other than those supported? No problem. We're currently working on support for other databases (including PostgreSQL, Oracle and DB2) but if you don't want to wait for us it's easy to write a data adapter for Tina. Just check out the wiki page and get going.
Anyhow, let's check out an example - how to connect and work with Microsoft SQL Server.
using TinaORM.Core;
using TinaORM.MsSql; // If you're using MySQL, the data adapter is in the namespace TinaORM.MySQL
...
string connectionString = "Data Source=..."
// Tina uses configuration objects to customize the database it uses, among other things.
// Configuration classes are derived from the TinaConfig class and are named after the appropriate database
// You can use the fluent interface, as shown here..
Tina tina = Tina.ConnectsTo<MsSql>(connectionString);
// Or you can initialize the configuration object manually
TinaConfig config = new MsSql(connectionString);
Tina tinaManual = new Tina(config);
Let's see some CRUD operations
MyAwesomeClass myAwesomeVariable = new MyAwesomeClass();
DoStuff(myAwesomeVariable);
string connectionString = "Data Source=..."
Tina tina = Tina.ConnectsTo<MsSql>(connectionString);
// Create
tina.Store(myAwesomeVariable);
// Read
var awesomePossums = from awesomeInstance in tina.Query<MyAwesomeClass>
where awesomeInstance.Order == "Didelphimorphia"
select awesomeInstance;
// Update
foreach (var possum in awesomePossums)
{
possum.Species = "Marmosa constantiae"; //White-bellied woolly mouse opossum, the king of Opossums
}
tina.SaveChanges();
// Delete
foreach (var possum in awesomePossums)
{
tina.Delete(possum);
}
That's about it. Next up, using custom serializers with Tina.