Sunday 11 September 2011

Application Programming with POCO

At long last, Pyrrho has its own POCO technology, which (I modestly claim) is much neater and easier to use than ADO.NET, LINQ, JPA etc. It all links well to the role-based conceptual models and REST service described in previous postings. Recall that a REST url for Pyrrho starts with (http or https) http://host:port/Database/Role/ Normally this is followed by table names and selectors. But a GET to this URL, returns a set of POCO definitions:
You can paste these class definitions into your application program. If this has been done for a MOVIE class in a database called Movies, the following simple code works:
using Pyrrho;
class Test
   public static void Main(string[] args)
       var db = new PyrrhoConnect("Files=Movies");
       var obs = db.Get("/MOVIE");
        foreach(MOVIE m in obs)
POCO stands for Plain Old CLR Object. The above example is using the following API in the PyrrhoConnect class:
Property or Method signatureExplanation
object[] Get(string rurl)Return the set of objects selected by the given relative URL
void Get(object ob,string rurl)The actual type of the object should match the first object returned by the URL. Fills the object with the data returned.
void Post(object ob)Installs the given object as a new row in the appropriate base table.
void Put(object old,object ob)The old object should have been obtained from the database using one of the Get methods above. ob should be an updated version of this: the database will be updated.
void Delete(object ob)The object should have been obtained from the database using one of the Get methods above. The object will be deleted from the database.
Needless to say, all the REST-style machinery can be used in the GET rurls. When you paste class definitions obtained from Pyrrho, you can add other things to these classes provided what you add is not public (e.g. use internal instead). This feature will be available in tomorrow's update to Pyrrho (along with some bugfixes to v4.5).


  1. This comment has been removed by the author.

  2. I have never even had the opportunity to try programming and who know, maybe today I would be a programmer in a some company. However, at this moment, the applications provided by are sufficient for me because I know that continuous upgrade of the native application making their better.