Is there any good sample ASP.NET MVC web application that uses SQLite? I thought of studying SQLite with ASP.NET. Any suggestions?
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);
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With