Skip to content
/ lp Public

Get started with LinqPad and the lprun cli scripting environment with one file

License

Notifications You must be signed in to change notification settings

mattjcowan/lp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lp

Getting Started

Get started with LINQPad and the lprun cli scripting environment with one file.

Clone the repo or download the setup.bat file:

powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/mattjcowan/lp/master/setup.bat -OutFile setup.bat"

From the command line, run:

.\setup.bat

Once everything is up and running, optionally add the directory to your path variable to easily run your scripts.

Refer to the LINQPad and lprun documentation for more information.

Script Library

Script Description
db-to-json.linq Exports a database schema to a json file. Source
static-gen.linq Generate code or files using handlebars templates, json data, and linq scripts. Source
serve-api.linq Run a ServiceStack Self-Hosted API, by specifying a port and assemblies with ServiceStack Services. Source

db-to-json.linq

This script will extract the schema of a database (MySql, SqlServer, Oracle, PostgreSql) and export it to a json file. Use this in combination with the static-gen.linq script to generate files and/or code from the json file.

Download the script:

powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/mattjcowan/lp/master/linqpad/queries/db-to-json.linq -OutFile .\linqpad\queries\db-to-json.linq"

Run the script:

.\linqpad\lprun.exe .\linqpad\queries\db-to-json.linq /dialect=SqlServer /output=adventureworks.json /connectionstring="Data Source=.\sqlexpress;Initial Catalog=AdventureWorks2014;Integrated Security=True"

static-gen.linq

This script executes the following:

  • Executes any *.linq files in a data directory and outputs the results of the scripts (if the result is valid JSON) to *.json files with the same name as the script.
  • Reads all *.json files in a data directory and adds them to the global dictionary context with the key being the name of the file (without the extension) and the contents the value
  • Compiles all *.hbs (handlebars) files in a templates directory starting with a "" character and registers them as partials, with the name of the partial being the name of the file (minus the "" character and without the extension)
  • Compiles and renders all other *.hbs (handlebars) files (passing in the global context populated from the data files above) and outputting them to a specified 'output' directory. No file extensions are added to the files; so the *.hbs template file names should have the intended extension as part of their name (i.e.: index.html.hbs, DbRepository.cs.hbs).

Download the script:

powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/mattjcowan/lp/master/linqpad/queries/static-gen.linq -OutFile .\linqpad\queries\static-gen.linq"

Run the script:

.\linqpad\lprun.exe .\linqpad\queries\static-gen.linq /data=aw\data /templates=aw\templates /output=aw\output

serve-api.linq

Rudimentary ServiceStack Self-Hosted API runner... For a more advanced dev server runner, check out sswc.

Download the script:

powershell -Command "Invoke-WebRequest https://raw.githubusercontent.com/mattjcowan/lp/master/linqpad/queries/serve-api.linq -OutFile .\linqpad\queries\serve-api.linq"

Run the script:

.\linqpad\lprun.exe .\linqpad\queries\serve-api.linq 1338 path\to\assembly1.dll path\to\assembly2.dll path\to\assembly3.dll

About

Get started with LinqPad and the lprun cli scripting environment with one file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published