C# 如何创建内存中的 sqlite 数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9173485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 06:15:03  来源:igfitidea点击:

How can I create an in memory sqlite database?

c#sqlite

提问by David Sykes

I have tried SQLiteConnection(":memory:")and SQLiteConnection("sqlite::memory:")but both of these fail with 'Invalid ConnectionString format'

我已经尝试过SQLiteConnection(":memory:")SQLiteConnection("sqlite::memory:")但是这两个都因“无效的 ConnectionString 格式”而失败

采纳答案by Yahia

try

尝试

var connection = new SQLiteConnection("Data Source=:memory:");

回答by gek0n

Maybe it's too late, but FullUri=file::memory:?cache=shared;is working.

也许为时已晚,但FullUri=file::memory:?cache=shared;正在发挥作用。

It's knowledge from forum question

这是来自论坛问题的知识

回答by everydayXpert

I'm using this:

我正在使用这个:

var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = ":memory:" };
var connection = new SQLiteConnection(connectionStringBuilder.ToString());