Home

Linqpad Web Server POC

http://www.youtube.com/watch?v=tUX26LiAe2g

In a nutshell... Create a Linqpad Script that generates data in any structure. Serialize it to JSON in one line with .Net. Use the results in your web XHR requests. Develop a web site with your browser, a text-editor, and Linqpad... with no extra deployment work. Keep the back-end simple because today's web apps require more "brain" work in Javascript. Not to mention frameworks like AngularJS pushe MVC completely to the browser, not the server tier.

This could be really big. It's a Web server I wrote in C# before I found out about Linqpad. One of my developers discovered Linqpad about 18 months ago and said..."If I just didn't have to cut and paste from Linqpad into Visual Studio, etc. It would be so much easier train other developers....". So I altered it to parse the Linqpad scripts.

I've got two versions of this server. The more powerful one is Domain specific. One of its main requirements was that the DataContext can be changed by the user (aka Data-Driven product with an end-user Data-Modeling component). The other is not so Domain specific, but it is meant for LINQ-SQL Custom Assembly drivers.

Let me know what you think...

Comments

  • I like it!

    A couple of ideas. First, have you thought about using this library to generate HTML directly from your scripts?

    Second, what would it take for LINQPad to compile and run your scripts? I've already enhanced Util.Run for the next beta to let you pass any number of parameters to a script, and return an object value. In other words, a query could look like this:

    string Main (string s, DateTime dt, bool flag = false)
    {
    ...
    }

    and you'd execute it from your web server by referencing LINQPad.exe and calling LINQPad.Util.Run as follows:

    string result = (string) await Util.Run (scriptFile, ... , "foo", DateTime.Now, true).ReturnValueAsync;

    The objects can be any serializable type and you can use default values to make interactive testing easier.

    Presumably, you'd also need to be able to run a query multiple times without the recompilation cost?
  • Hyperlinq would be used in your script when your script's purpose is to generate HTML. These days, the bulk of web requests are for pure data, either serialized in JSON or XML. In fact, the latest greatest Javascript frameworks generate most your HTML (aka DOM) inside the browser. Web servers are more and more just generating a stub of html and let the javascript Bootstrap insert the rest.

    The way I see it, there are a few extra concerns you've got to build in around lprun.exe...

    First is ability for the script to say what mime-type is being returned. text/html, text/css, text/script, etc. It's part of the HTTP response headers. It would be nice if it was additional meta-data around the script.

    The second concern is script life-cycle management and recompilation cost. Added to Util.Run, maybe you could have... Util.Compile() and/or Util.ReRun(). With Util.Compile() you want to keep track if a script has changed since the last time you ran it. Another assumption is that scripts can declare static variables that persist for the life of the compiled script (cache). In my server, you can send it a "resetcache" in the URL, and it basically discards all the compiled scripts so they lose their static data.

    The third concern is Deployment in an Enterprise. For example, you develop the scripts in your "DEV" environmnet, deploy to QA, then deploy to PROD. You want to be able to abstract away the connection details from the .LINQ file so they are exactly the same files in each environment.

    --
  • Util.Compile is now available in the new beta, as is the ability to pass typed values in/out of queries:
    http://www.linqpad.net/beta.aspx

    For info, see Help | What's new.
  • Is there a way to set the Plugins folder from MyExtensions from the Linqpad.exe command line? I've got a few different versions of Linqpad.exe and I'd like to have a different My Extensions folder for each version without having to "Set Folder". Also, hopefully I can set this programmatically when using Util.Compile/Run.
  • In each place you've got LINQPad.exe, create a subfolder called 'plugins'. LINQPad will then use this in preference to the global default.
Sign In or Register to comment.