This project is read-only.

See also the Rationale.

The sample below shows the basic usage of Stormy.

In only 50 lines of code, we create a model, a mapper, and use it in a main program.

Of course, your database and table should exist before, we assume here:

  1. a database called stormy (in SQL Server), adapt your connection string if necessary
  2. a table called cats, created by something like this: create table cats(name nvarchar(16), weight real); 
  3. table is filled with some cats by lines like this: insert into cats(name, weight) values('Sockington', 5.5);

Other Quick Start pages:


using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

// 0. Use stormy
using Stormy;

// 1. Create a "Model" (usually, we have one already)
public class Cat
    public string Name { get; set; }
    public float Weight { get; set; }

// 2. Create a "Mapper" 
public class CatMapper : ISelectable<Cat>
    public Cat ApplySelect(IDataReader reader)
        return new Cat()
                Name = reader["name"].ToString(),
                Weight = (float)reader["weight"]

namespace StormyQuickStart
    class Program
        static void Main(string[] args)
            // 3. Register the mapper, such that CatMapper is used for model Cat
            Orm.Register<Cat>(new CatMapper());

            // 4. Create the connection (connection strings are just ADO.NET)
            var connection = new Stormy.Connection(new SqlConnection(
                        Data Source=localhost\SQLEXPRESS;
                        Initial Catalog=stormy;
                        Integrated Security=SSPI;

            // 5. Get list of models (here Cats) using plain SQL statements
            foreach (var cat in connection.Select<Cat>("select * from cats"))
                System.Console.WriteLine("Cat {0} is {1}", cat.Name, cat.Weight);

Last edited Jan 1, 2012 at 10:56 PM by barendgehrels, version 29


No comments yet.