开发者

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 t开发者_运维百科he 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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜