是否有 LinqPad nutshell 数据库的 SQLite 版本

发布于 2024-12-09 11:12:17 字数 166 浏览 1 评论 0原文

我正在尝试使用 LINQPad 学习 LINQ,但事实是我有一个笔记本。

因此,我不想在其上安装 SQL Server(我什至不相信我可以做到这一点)。

一些 LINQPAD 示例使用名为 nutshell.mdf 的数据库,我想知道是否可以找到该数据库的 SQLite 版本,在哪里?

I am trying to learn LINQ with LINQPad, but the fact is that I have a notebook.

Therefore, I don't want to install SQL Server on it (I am not even conviced that I could do it).

Some LINQPAD Examples use a database called nutshell.mdf, I'd like to know if I can find a SQLite version of this database, and where?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗喜 2024-12-16 11:12:17

没有 SQLite 版本,但您可以轻松创建 SQL CE 版本。 SQL CE 相当轻量级,不会让您的笔记本陷入困境。 LINQPad支持SQL CE:单击“添加连接”,选择LINQ to SQL,单击SQL CE并告诉它创建数据库,然后单击“确定”。然后运行“SQL”类型的查询来创建架构 - 以下脚本将创建 Nutshell 示例数据库:

create table Customer
(
    ID int not null primary key,
    Name nvarchar(30) not null
)
go
create table Purchase
(
    ID int not null primary key,
    CustomerID int null references Customer (ID),
    Date datetime not null,
    Description nvarchar(30) not null,
    Price decimal not null
)
go
create table PurchaseItem
(
    ID int not null primary key,
    PurchaseID int not null references Purchase (ID),
    Detail nvarchar(30) not null,
    Price decimal not null
)
go
create table MedicalArticles
(
    ID int not null primary key,
    Topic nvarchar (20),
    Abstract nvarchar (2000)    
)
go
create table Product
(
    ID int not null primary key,
    Description nvarchar(30) not null,
    Discontinued bit not null,
    LastSale datetime not null
)
go
insert Customer values (1, 'Tom')
go
insert Customer values (2, 'Dick')
go
insert Customer values (3, 'Harry')
go
insert Customer values (4, 'Mary')
go
insert Customer values (5, 'Jay')
go
insert Purchase values (1, 1, '2006-1-1', 'Bike', 500)
go
insert Purchase values (2, 1, '2006-1-2', 'Holiday', 2000)
go
insert Purchase values (3, 2, '2007-1-3', 'Bike', 600)
go
insert Purchase values (4, 2, '2007-1-4', 'Phone', 300)
go
insert Purchase values (5, 3, '2007-1-5', 'Hat', 50)
go
insert Purchase values (6, 4, '2008-1-6', 'Car', 15000)
go
insert Purchase values (7, 4, '2008-1-7', 'Boat', 30000)
go
insert Purchase values (8, 4, '2008-1-8', 'Camera', 1200)
go
insert Purchase values (9, null, '2008-1-9', 'Jacket', 80)
go
insert PurchaseItem values (1, 2, 'Flight', 1500)
go
insert PurchaseItem values (2, 2, 'Accommodation', 500)
go
insert PurchaseItem values (3, 2, 'Camera', 400)
go
insert MedicalArticles values (1, 'Influenza', '<this is the abstract...>')
go
insert MedicalArticles values (2, 'Diabetes', '<this is the abstract...>')
go
insert Product values (1, 'Widget', 0, '2007-1-1')

There's no SQLite version, but you can create a SQL CE edition easily enough. SQL CE is fairly lightweight and won't bog down your notebook. LINQPad supports SQL CE: click "Add Connection", choose LINQ to SQL, click SQL CE and tell it to create a database, and click OK. Then run a query of type 'SQL' to create the schema - the following script will create the Nutshell sample database:

create table Customer
(
    ID int not null primary key,
    Name nvarchar(30) not null
)
go
create table Purchase
(
    ID int not null primary key,
    CustomerID int null references Customer (ID),
    Date datetime not null,
    Description nvarchar(30) not null,
    Price decimal not null
)
go
create table PurchaseItem
(
    ID int not null primary key,
    PurchaseID int not null references Purchase (ID),
    Detail nvarchar(30) not null,
    Price decimal not null
)
go
create table MedicalArticles
(
    ID int not null primary key,
    Topic nvarchar (20),
    Abstract nvarchar (2000)    
)
go
create table Product
(
    ID int not null primary key,
    Description nvarchar(30) not null,
    Discontinued bit not null,
    LastSale datetime not null
)
go
insert Customer values (1, 'Tom')
go
insert Customer values (2, 'Dick')
go
insert Customer values (3, 'Harry')
go
insert Customer values (4, 'Mary')
go
insert Customer values (5, 'Jay')
go
insert Purchase values (1, 1, '2006-1-1', 'Bike', 500)
go
insert Purchase values (2, 1, '2006-1-2', 'Holiday', 2000)
go
insert Purchase values (3, 2, '2007-1-3', 'Bike', 600)
go
insert Purchase values (4, 2, '2007-1-4', 'Phone', 300)
go
insert Purchase values (5, 3, '2007-1-5', 'Hat', 50)
go
insert Purchase values (6, 4, '2008-1-6', 'Car', 15000)
go
insert Purchase values (7, 4, '2008-1-7', 'Boat', 30000)
go
insert Purchase values (8, 4, '2008-1-8', 'Camera', 1200)
go
insert Purchase values (9, null, '2008-1-9', 'Jacket', 80)
go
insert PurchaseItem values (1, 2, 'Flight', 1500)
go
insert PurchaseItem values (2, 2, 'Accommodation', 500)
go
insert PurchaseItem values (3, 2, 'Camera', 400)
go
insert MedicalArticles values (1, 'Influenza', '<this is the abstract...>')
go
insert MedicalArticles values (2, 'Diabetes', '<this is the abstract...>')
go
insert Product values (1, 'Widget', 0, '2007-1-1')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文