3

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?

Jeff LaFay
  • 12,882
  • 13
  • 71
  • 101
GianT971
  • 4,385
  • 7
  • 34
  • 46
  • You could probably install express but I'm not sure how well it would work. Since the .mdf is the author's example, they probably don't have a SQLite version. I'm not even sure if you could fully explore LINQ like you would want to with SQLite. You might just have to suffer with express or learn on a different machine. – Jeff LaFay Oct 11 '11 at 20:47

1 Answers1

7

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')
Joe Albahari
  • 30,118
  • 7
  • 80
  • 91
  • 3
    Joe, your support to LINQPad users in unparalleled. Very nice! – Jeff LaFay Oct 12 '11 at 13:51
  • According to THE LINQPad site (http://www.linqpad.net/), "And that's not all - there's also specific support for: SQL Azure, SQL Table Storage, Oracle, SQLite " - is this new? Is there an example that shows how to connect to SQLite? I've been able to connect to my SQL Azure (SQL DB) tables without a hitch, but would like to be able to connect to my local SQLite tables, too, via LINQPad. BTW: Thanks for this great tool! I did buy your "C# 5.0 in a Nut's Hell" book. I tried the "Check for Updates" and it told me I've got the latest version of LINQPad; but I see no SQLite option... – B. Clay Shannon-B. Crow Raven Nov 26 '12 at 17:42
  • 1
    Oh, I see - the "View More Drivers" link at the bottom of the connection page leads to the SQLite-specific driver download...and it works like a champ! Thanks again! Who said there's no such thing as a free utility? – B. Clay Shannon-B. Crow Raven Nov 26 '12 at 17:56
  • Also, to install drivers in an offline environment: "If you click the "Add Connection" button at the top of the connections panel it will open the "Choose Data Context" dialog. At the bottom-left of that dialog there is a button to "View more drivers..." - just click that button to see a final dialog presented that lists out a few of the drivers, and a button at the bottom-left labelled "Browse..." that will allow to pick that .LPX file and load up the CRM driver." http://forum.linqpad.net/discussion/566/how-to-install-plug-ins – user2441511 Aug 11 '17 at 20:56