|
If you haven't yet discovered
LinqPad and you are using LINQ, you need to know
that its a very cool LINQ query tool. Its
also a C#/VB/F# scratchpad which instantly executes any
expression, statement block or program with rich output
formatting. LinqPad standard edition is free, and
for a small fee you can have the full version which
enables Autocompletion. This tool is used by many
developers around the world - including at Microsoft.
We have written a LinqPad driver for FileDb. Now
you can query FileDb database files in LinqPad just as
you would a SQL Server database. For example, to
query for and display all Customers you would use this
LINQ query: |
|

Download LinqPad |
var q = from c in Customers select c;
q.Dump();
|
To select specific fields, you use [] either by
ordinal index or field name.
var q = from c in Customers
select new
{
CustomerId = c["CustomerID"],
CustomerName = c["CompanyName"]
}
q.Dump();
|
The screenshot below shows LinqPad with a FileDb
connection open and a query joining 3 tables, Customers,
Orders and OrderDetails. Notice the automatic
formatting of the output.

Installing the FileDb LinqPad
Driver
Download
the Zip
file and unzip it to a folder. Of course you
must also download/install LinqPad. Once you have
done this, open LinqPad and click the "Add Connection"
link in the Connections list. You will be
presented with the "Choose Data Context" dialog shown
below.

Click the "View more Drivers" button at the bottom
left (circled red). You will then be presented
with the "Choose a Driver" dialog, shown here.

Click the "Browse to a .LPX file" button at bottom
left. This will open a browse dialog allowing you
to find and select the FileDbDynamicDriver.lpx file in
the folder where you have unzipped it.

Now you're ready to begin using FileDb with LinqPad.
You will now see the FileDb Driver in the "Choose Data
Context" dialog. When you select it and click
Next, you will see the FileDb Connection dialog, shown
here.

In the Zip file download, there is included the
Northwind database files and some some LinqPad script
files. Browse to the folder where you unzipped
these files and select the Northwind Database folder.
Your dialog should now look like the screenshot above.
Click OK and you are ready to begin querying the
Northwind database tables. Use the sample script
files to help you get started.
|