public void GridExample_GetTransactionKeyFor(
            string e,

            Action<string> y)
        {
            var x = new __ConsoleToDatabaseWriter(AtConsole);

            grid.SelectTransactionKey(
                ContentKey =>
                {
                    y("" + ContentKey);
                }
            );
            x.Dispose();

        }
        public void __grid_SelectContent(
            string e,
            Action<string, string, string, string> y,
            Action<string> AtTransactionKey = null,
            Action<string> AtError = null
            )
        {
            //ScriptCoreLib.PHP.Native.API.error_reporting(0);

            //GridExample_InitializeDatabase("", delegate { });

            // will we run out of memory now?
            // <b>Fatal error</b>:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 65488 bytes) in <b>B:\inc\SQLiteWithDataGridView.ApplicationWebService.exe\class.SQLiteWithDataGridView.__ConsoleToDatabaseWriter.php</b> on line <b>62</b><br />

            var x = new __ConsoleToDatabaseWriter(AtConsole);
            Console.WriteLine("inside __grid_SelectContent");
            //x.Dispose();

            try
            {
                InternalSelectContent(y, AtTransactionKey);

            }
            catch (Exception ex)
            {
                // script: error JSC1000: Java : Opcode not implemented: brtrue at SQLiteWithDataGridView.ApplicationWebService.__grid_SelectContent
                AtErrorOrThrowIt(AtError, ex);

            }

            x.Dispose();
        }
        public void GridExample_UpdateItem(

                string ContentKey,
                string ContentValue,
                string ContentComment,

                 Action<string> AtTransactionKey = null
            )
        {
            var x = new __ConsoleToDatabaseWriter(AtConsole);
            Console.WriteLine("inside GridExample_UpdateItem");

            var iContentKey = int.Parse(ContentKey);

            grid.Update(
                new TheGridTableQueries.Update
                {
                    ContentKey = iContentKey,
                    ContentValue = ContentValue,
                    ContentComment = ContentComment
                }
            );


            grid.InsertLog(
                new TheGridTableQueries.InsertLog { ContentKey = iContentKey, ContentComment = "UpdateItem" }
            );

            if (AtTransactionKey != null)
                GridExample_GetTransactionKeyFor("", AtTransactionKey);


            Console.WriteLine("exit GridExample_UpdateItem");
            x.Dispose();
        }
        public Task GridExample_EnumerateItemsChangedBetweenTransactions(


            string FromTransaction,
            string ToTransaction,
            Action<string, string, string, string> AtContent

        )
        {
            var x = new __ConsoleToDatabaseWriter(AtConsole);


            var xParentContentKey =
                string.IsNullOrEmpty(
                ParentContentKey)
                ? null : (object)int.Parse(ParentContentKey);

            grid.SelectContentUpdates(
                new TheGridTableQueries.SelectContentUpdates
                {
                    FromTransaction = int.Parse(FromTransaction),
                    ToTransaction = int.Parse(ToTransaction),

                    ParentContentKey1 = xParentContentKey,

                    // android 2.2 prepared statements disallow null params? send empty string instead?
                    ParentContentKey3 = xParentContentKey,

                    ParentContentKey2 = xParentContentKey
                },
                reader =>
                {
                    string
                       ContentValue = reader.ContentValue,
                       ContentComment = reader.ContentComment;

                    long
                        ContentKey = reader.ContentReferenceKey,
                        ContentChildren = reader.ContentChildren;

                    AtContent("" + ContentKey, ContentValue, ContentComment, "" + ContentChildren);
                }
            );



            x.Dispose();

            // why does jsc not support parameterless yields?

            return Task.FromResult(default(object));
        }
        public void GridExample_AddItem(
            string ContentValue,
            string ContentComment,

            Action<string> AtContentReferenceKey

            )
        {
            var x = new __ConsoleToDatabaseWriter(AtConsole);
            Console.WriteLine("inside GridExample_AddItem");



            var xParentContentKey = ParentContentKey == "" ? null : (object)int.Parse(ParentContentKey);

            grid.Insert(
                new TheGridTableQueries.Insert
                {
                    ContentValue = ContentValue,
                    ContentComment = ContentComment,
                    ParentContentKey = xParentContentKey
                },

                ContentReferenceKeyLong =>
                {
                    // jsc does not yet autobox for java 
                    // int cannot be dereferenced
                    var ContentReferenceKey = ContentReferenceKeyLong.ToString();
                    //var ContentReferenceKey = ((object)ContentReferenceKeyLong).ToString();

                    grid.InsertLog(
                         new TheGridTableQueries.InsertLog { ContentKey = (int)ContentReferenceKeyLong, ContentComment = "AddItem" }
                     );

                    if (ParentContentKey != "")
                    {
                        grid.InsertLog(
                           new TheGridTableQueries.InsertLog { ContentKey = int.Parse(ParentContentKey), ContentComment = "ChildAdded" }
                       );

                    }

                    AtContentReferenceKey(ContentReferenceKey);
                }
            );


            x.Dispose();

        }