English 中文(简体)
SubSonic 3 Repository - SQLite In-Memory
原标题:

Before I invest the time in modifying the SubSonic 3 source, I figured I ask to see if I m missing something simple.

Is it possible to use the SubSonic 3 Repository with migrations on a SQLite In-Memory database? I couldn t find a way to force the DbDataProvider to keep the connection open so the In-Memory SQLite database doesn t vanish when the connection get s closed.

The unit test with the connection string I was trying is...

public class SQLite_InMemory_SimpleRepositoryTests
{
    public class Job
    {
        public Guid JobId { get; set; }
        public string JobName { get; set; }
    }

    [Fact]
    public void SQLite_InMemory_SimpleRepo_CanStayOpen()
    {
        IDataProvider provider = ProviderFactory.GetProvider("Data Source=:memory:;Version=3;New=True;Pooling=True;Max Pool Size=1;", "System.Data.SQLite");
        IRepository repository = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);

        for (int i = 0; i < 10000; i++)
        {
            var job = new Job {JobId = Guid.NewGuid(), JobName = "Job_"+i};
            repository.Add(job);
        }
    }
}

I tried setting the "Shared Connection" on the IDataProvider, but the connection still seemed to close.

If not, I ll update the SubSonic source, and submit the changes.

Thanks!

最佳回答

Interesting - no there s no way that I can think of to do this other than maybe creating a static IDataProvider but even then we close off the connection for doing things like executing scalar s etc.

I spose you could create such a thing by implementing the IDataProvider then setting things up as you need - all the execution goes through it. But this is making me wonder if we explicitly shut things down in the calling code - which would be bad design on my part... hmmm.

Would love to have this feature...

问题回答

暂无回答




相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签