Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite with ASP.NET MVC [closed]

Is there any good sample ASP.NET MVC web application that uses SQLite? I thought of studying SQLite with ASP.NET. Any suggestions?

like image 987
ACP Avatar asked Dec 08 '10 04:12

ACP


1 Answers

SQLite uses the same provider model as ADO.NET. So pick any tutorial you like about SQL Server and replace SqlConnection with SQLiteConnection. I wrote a sample application using FluentNHibernate with SQLite you may take a look at.

Or if you don't use an ORM, simply declare a method in your repository and you are good to go:

public IEnumerable<int> GetIds()
{
    using (var conn = new SQLiteConnection(SomeConnectionString))
    using (var cmd = conn.CreateCommand())
    {
        conn.Open();
        cmd.CommandText = "SELECT id FROM foo";
        using (var reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                yield return reader.GetInt32(0);
            }
        }
    }
}
like image 58
Darin Dimitrov Avatar answered Sep 29 '22 22:09

Darin Dimitrov