我正在尝试用LINQPad学习LINQ,但事实是我有一个笔记本。
因此,我不想在上面安装SQL Server(我甚至不相信我能做到这一点)。
一些LINQPAD示例使用了一个名为nutshell的数据库。mdf,我想知道我是否能找到这个数据库的SQLite版本,在哪里?
没有SQLite版本,但您可以轻松创建SQL CE版本。SQL CE是相当轻量级的,不会使您的笔记本陷入困境。LINQPad支持SQL CE:点击"Add Connection",选择"LINQ to SQL",点击SQL CE命令创建数据库,点击"OK"即可。然后运行'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')