Transacted apps

November 12, 2015 9:12 pm Published by Leave your thoughts

Ever wrote a C# Console Application? Please do. Here’s one for you.

app.cs

using System;

public class Person {
  public string FirstName;
  public string LastName;

  public string FullName {
    get { return FirstName + " " + LastName; }
  }
}

class Program {
  static void Main() {
    var p = new Person() { FirstName = "Flavor", LastName = "Flav" };
    Console.WriteLine("{0} is in the house!", p.FullName);
  }
}

If you like, go compile it and run it.

Flavor Flav is in the house!

It’s quite beautiful in all its simplicity, right?

What if we could also store that data, query it and expose it in a browser?

Enter Starcounter

Install Starcounter. Just hit install to settle with the defaults.

Our aim at Starcounter is to deliver a new platform for building next-generation business applications, to put that in the hands of talents and thereby provide them a fast path to invent and deliver something with a big impact. While being an enabler of realizing big ideas, we still believe that everything big always start small, usually at someones desktop – yours. The road to huge goes through composition of small and best of bread.

You might have read about how Starcounter allow you to collapse the stack, how you can enjoy the ultra-fast database engine to deliver server-side view model driven web applications using the built in REST style server and how such apps can be orchestrated into larger end-user applications.

That’s a big promise. But we feel confident in it because underneath it all, we have used a similar approach to bring Starcounter to where it is today.

Apps, SQL and the web

This mini blog series will show you a few of the underlying key essentials;

  1. the anatomy and working of micro-level transacted apps, to store,
  2. the built-in SQL API to query, and
  3. web handlers to expose your applications data.

Transacted apps in the database

With Starcounter installed, open a command prompt, get that app.cs file from above and do this:

C:\Users\Per> star -t app.cs
app -> default (started, default port 8080, admin 8181)
Flavor Flav is in the house!

The star command launch applications inside a Starcounter database. The -t ([fusion_builder_container hundred_percent="yes" overflow="visible"][fusion_builder_row][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][--transact] shorthand) wraps that Main entrypoint inside a write transaction.

You can still see the output in the console. But you’ll also notice an additional message, indicating your application now runs inside the Starcounter.

Now open up a browser and point it to localhost:8181/sql. In the SQL box, type SELECT * FROM Person and hit Execute.

SELECT * FROM Person

Next: the SQL API

In this text, you’ve taken the source code of a standard C# Console Application and turned that into a database application, simply by running it with the star command. Without modifications, and not even compiling it.

Stay tuned for the next part of this blog series, which will introduce you to the super-simple SQL API, enabling these apps to access data from within the application.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Tags: , ,

Categorised in:

This post was written by Per Samuelsson

Leave a Reply

Your email address will not be published. Required fields are marked *