开发者

Is there a SQLite version of the LinqPad nutshell database

开发者 https://www.devze.com 2023-04-12 03:12 出处:网络
I am trying to learn 开发者_如何学GoLINQ with LINQPad, but the fact is that I have a notebook.

I am trying to learn 开发者_如何学GoLINQ 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?


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')
0

精彩评论

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

关注公众号