RingDotNetfor Ring

Function index

Every function and class method of the Ring library, generated from the source files — with the comment that documents it.

This page is generated from the comments in libraries/dotnetlib/*.ring. Search it with the box at the top of the page.

Core (functions.ring)#

FunctionDescription
dnRequest(cOperation, aParameters)Send a request to the bridge: dnRequest("call", [oTarget, "Method", arg1, ...]), returns one value. The common answers (a text, a number, a yes/no, one object) are read directly, without making a list of items.
dnSend(cOperation, nHandle, cName, cArgs)The request of a generated method for a member of an object: the operation and the name are ready wire items ("s4:call", "s6:Append"), the handle is a number (0 is the null object) and the arguments are packed. It makes the same request text as dnRequest, without a list and a DotNetObject for the target (about 40% of the time of a call).
dnExchange(cRequest)Send a request text to the bridge and read the answer
dnFinish(cResponse)The answer of the bridge (one item, or a list of items) as a Ring value
dnAnswer(xAnswer)The answer of a typed call (dotnet_getp, dotnet_callt, dotnet_calltd): a number or a text as it is; anything else (a null text, an object, from the generic request that the extension made) comes as the marker list that dnFinish reads. A call to this function costs less than the same statements in the generated method.
dnFlush()The handles of the objects that Ring freed are released in groups (the next .NET call does it when 32 are waiting). dnFlush() releases them now. Ring frees an object a little after the last variable that held it is gone; callgc() (called in the same function) makes it free the objects at once. So to let go of a big object now (or before you look at the memory of .NET with GC.GetTotalMemory) write: oBig = NULL callgc() dnFlush()
dnHandleCount()The number of .NET objects that Ring holds now (handles in the table of the bridge): a test of the release of handles compares it before and after the objects were dropped (call callgc() and dnFlush() first)
dnVersion()Version of the .NET runtime that is hosted in this process
dnLoad(cPath)Load an assembly (.dll) from a path, returns the assembly name
dnLoadName(cName)Load an assembly by name (for example "System.Xml")
dnType(cTypeName)Get a type (to call its static members), for example dnType("System.Math")
dnNew(cTypeName, aParameters)Create a .NET object: dnNew("System.Text.StringBuilder", ["Hello"]) The arguments can be named: dnNew("StringBuilder",[ :value = "Hello", :capacity = 64 ]) chooses the constructor by the parameter names (the order does not matter). The class is a full .NET type name or the name of a generated Ring class (see dnImport)
dnStatic(cTypeName, cMethod, aParameters)Call a static method: dnStatic("System.Math", "Max", [3, 9])
dnCallNamed(nTarget, cMethod, aParameters)A call by the name of the method (callMethod, dnStatic): the extension packs the arguments and reads any answer. nTarget is the handle of the object or of the type.
dnObj(xInfo)The answer of dotnet_callo (a call that returns an object): the extension answers the text "<handle>|<type>|<base type>..." and the Ring function wraps it as the generated class of the type; null is 0; any other answer is the list [1, answer] that dnFinish reads.
dnMakePrototype(cFactory)Make the ready object of the class of a factory function (no handle, no guard) once, and keep it in aDotNetPrototypes
dnAny(aAnswer)The answer of dotnet_calla (any answer): the extension answers a text, a number or a yes/no itself and an object as the list [2, "<handle>|<type>..."]
dnTypeHandle(cTypeName)The handle of the type object of a type name, made once (the generated static methods pass it as a number: returning the cached type object itself would copy it at every call)
dnTypeItem(cTypeName)The wire item of a type (its handle), made once for each type name
dnNewHandle(cOperation, cTypeName, cArgs)Make an object and read its handle from the answer: the answer is a number, so the object is not wrapped for Ring (0: a value such as an Int32 has no object, its class is used for static members)
dnIsNamed(aValue)True for a list of [name, value] pairs, the way Ring passes named arguments: [ :server = "x", :port = 80 ] ([] too)
dnCreateNamed(cTypeName, aNamed)The handle of an object created with named arguments (used by generated code)
dnDescribe(cTypeName)Public API of a type (used by tools/dotnettools/gendotnet.ring)
dnCallback(cCode)Ring code callable from .NET: dnCallback("? aDotNetArgs[1]") or dnCallback("myfunc"), then pass it where a delegate is expected. Code in a text reads the arguments from aDotNetArgs and sets xDotNetResult. The NAME of a function is called with the list of the arguments (func myfunc aArgs) and its return value is the result. The code is compiled once into a function (the same code gives the same function). A callback runs on the Ring thread, while a call from Ring is running (see the page "Rules and limits").
dnUseDesktop()Use Windows Forms / WPF (adds the Windows Desktop runtime). Call it before any other .NET call.
dnImport(cNamespace)Load the generated Ring classes of a .NET namespace: dnImport("System.IO"). using { "System.IO" } calls it for each name.
dnImportFrom(cFolder, cNamespace)Load classes generated by tools/dotnettools/wrapassembly.ring for your own assembly: dnImportFrom("myclasses/","MyCompany.Tools")
dnGenericName(cType, aArguments)Name of a closed generic type: dnGenericName("System.Collections.Generic.List",["System.Int32"])
dnBox(cType, nValue)A value of an exact .NET type for a parameter of type object: a whole number that goes to an object is an Int32 (Ring has one kind of number), so dnBox("System.Double",10) is the Double 10, dnBox("System.Int64",5) the Int64 5 (also Single, Decimal, Byte ...)
dnNewGeneric(cType, aArguments, aParameters)Create an object of a generic type without a generated class (a DotNetObject: use callMethod/getProp)
dnAssert(cName, xActual, xExpected)Simple test helpers: dnAssert("name",actual,expected) ... dnTestSummary(). Numbers are compared with a small tolerance, texts exactly (binary data too: a text can hold any byte). A failure prints one line: FAIL: name expected <..> got <..>
dnTestSummary()Print "TESTS: n passed, m failed" and return the number of failures
dnRegisterClass(cType, cClass, nInit)Register a generated class: objects of this .NET type are returned as instances of the Ring class
dnLoadClassIndex()The index of the generated classes ([type, namespace] pairs) is a file of about six thousand entries: it is loaded when it is first needed (an object comes back whose class is not loaded yet), not when a program starts
dnAddClassIndex(aItems)Called by the index files that the generators write: dnAddClassIndex([ ["System.IO.File","System.IO"], ... ])
dnBuildIndexMap()The index of the generated classes as a hash table (type --> namespace); built once, when it is first needed
dnWrapInto(cInfo)The same, but the object is left in the global oDotNetNew (returning it would copy it once more: a class can have 100 attributes)
dnFindFactory(cChain)The factory function for a chain "type|base type|..." (the most specific type first: a type that is not imported yet is imported on demand before a less specific one is used), or "-" when no class is known
dnClassOfType(cType)The Ring class of a .NET type name: the namespace of the type is imported when it is not loaded yet; "" when there is no class
dnCombinedFactory(aClasses)The factory of a combined class. Ring has one parent for a class, and an object that is two interfaces at once (IElement and IContainer: Text() is a method of the second) needs the members of both, so a class is made once for the list of classes: it derives from the first, and the methods of the others are merged into it. A wrapper method does nothing but send the name of its method to the bridge, so a method works on any object that has it, whichever interface it was made for.
dnMakeMix(cMix, aClasses)
dnClassAttributes(cClass)The attributes of a generated class (the names in lower case)
dnMergeClass(cDestination, cClass)Merge the methods of a class, then of the class it derives from..., into another class (the classes of DotNetObject are in every class already)
dnEnsureExt(cClass)The static class with the extension methods that a generated method calls: its assembly is loaded by the bridge the first time
dnNull()The .NET null: oPictureBox.Image = dnNull()
dnIsNull(xValue)Is the value the .NET null? True for a null object, false for every other value (a number, a text, a list, an object that is not null)
dnBuffer(xSizeOrBytes)A byte buffer that .NET can fill: oBuffer = dnBuffer(1024) makes a byte[] of 1024 bytes, dnBuffer("bytes") one with the bytes of a text. A byte[] that .NET returns is a Ring text (a copy), and a Ring text passed in is a new array, so a method that FILLS an array (Stream.Read, Socket.Receive...) needs this object: pass it as the byte[] parameter and read what was written with dnBufferBytes. n = oStream.Read(oBuffer,0,1024) cBytes = dnBufferBytes(oBuffer,n)
dnBufferBytes(oBuffer, nCount)The first nCount bytes of a buffer as a Ring text (use the number that Read or Receive returned; dnBufferSize(oBuffer) for all of them)
dnBufferSize(oBuffer)The size of a buffer in bytes
dnUseWeb()Use ASP.NET Core (adds the ASP.NET runtime and loads the web server of RingDotNet). Call it before any other .NET call.
dnUseAll()Windows Forms / WPF and ASP.NET Core together (using { } starts it when the names of both are used). Call it before any other .NET call.
dnUseData()Use Entity Framework Core with SQLite (loads the data assembly of RingDotNet and its packages)
dnLoadSelfTest()The checks of a program with a window are kept in a file of their own, so the sample stays a clean program: next to the program, the file selftest/<name of the program>.ring defines func selfTest(). When the program runs with --selftest, uiRun() (or wpfRun()) loads that file, runs selfTest() once the window is shown, closes the window and prints the result. Returns True when such a file was loaded.

DotNetObject and friends (classes.ring)#

FunctionDescription
DotNetObject.init(pHandle)(the parameter has another name: "this.nHandle = ..." would run Ring's property setter machinery, which breaks an outer assignment like oForm.Text = new Path().GetFileName(...))
DotNetObject.dnDefaultObject(cTypeName)The default object of a class (used by the class body of the generated classes, for "new X" without parentheses)
DotNetObject.isNull()True for the null reference
DotNetObject.callMethod(cMethod, aParameters)Call a method by its name: oObject.callMethod("Append", ["text"]). It works for every .NET object, also when no class was generated.
DotNetObject.callGeneric(cMethod, aTypeArguments, aParameters)Call a generic method whose type argument only its result shows (JsonConvert.DeserializeObject<T>(json)): the type arguments are a list of type names, then the arguments: oType.callGeneric("DeserializeObject",["System.Collections.Generic.List`1[[System.String]]"],[cJson])
DotNetObject.convertTo(cType)The conversion of the object to a .NET type with the operators op_Implicit / op_Explicit (the cast of C#): oToken.convertTo("System.String")
DotNetObject.getProp(cMember)Read a property or a field
DotNetObject.setProp(cMember, xValue)Write a property or a field
DotNetObject.toString()ToString() of the object
DotNetObject.typeName()Full name of the .NET type
DotNetObject.toList()Copy the items of an array or collection to a Ring list
DotNetObject.asyncEnumerator()An IAsyncEnumerable (a method that returns one has no await foreach in Ring): toList() reads all the items. One item at a time: oEnum = oStream.asyncEnumerator() while oEnum.asyncNext() ? oEnum.Current end oEnum.asyncDispose()
DotNetObject.asyncNext()Wait for the next item of an async enumerator: true when there is one (it is Current), false at the end
DotNetObject.asyncDispose()End an async enumerator (toList does it by itself)
DotNetObject.release()Release the reference kept by the bridge now (the object is not used after this). Ring releases it by itself when the last variable that holds the object is gone (see oDotNetGuard); this is only needed to let go of a big object at once.
DotNetOwned.init(pHandle)a .NET object that Ring owns: pHandle is its handle, which is released when the Ring object is dropped
DotNetCallback.init(pCode)keep the Ring code (a text of code or the name of a function) that .NET runs when it calls the delegate

LINQ (linq.ring)#

FunctionDescription
dnQuery(xSource)A query on a Ring list or a .NET collection: dnQuery(aList).Where("...").ToList()
DotNetQuery.init(xSource)a query on xSource, a Ring list or a .NET collection (made by dnQuery)
DotNetQuery.Where(cCode)the items for which the code gives true
DotNetQuery.Select(cCode)the code applied to every item (the results are the new items)
DotNetQuery.SelectMany(cCode)the code gives a list for every item; the lists are joined into one
DotNetQuery.OrderBy(cCode)sort by the value that the code gives for an item
DotNetQuery.OrderByDescending(cCode)sort by the value that the code gives, the largest first
DotNetQuery.ThenBy(cCode)after OrderBy: sort items with the same value by another value
DotNetQuery.ThenByDescending(cCode)after OrderBy: sort items with the same value by another value, the largest first
DotNetQuery.TakeWhile(cCode)the items from the start, while the code gives true
DotNetQuery.SkipWhile(cCode)leave out the items from the start, while the code gives true
DotNetQuery.Take(nCount)the first nCount items
DotNetQuery.Skip(nCount)leave out the first nCount items
DotNetQuery.Distinct()every value once
DotNetQuery.Reverse()the items in the opposite order
DotNetQuery.Concat(oOther)the items followed by the items of oOther (a query, a list or a .NET collection)
DotNetQuery.Union(oOther)the values of both sources, every value once
DotNetQuery.Intersect(oOther)the values that both sources have
DotNetQuery.Except(oOther)the values of this source that oOther does not have
DotNetQuery.ToList()run the query: the result as a Ring list
DotNetQuery.Count()the number of items
DotNetQuery.CountWhere(cCode)the number of items for which the code gives true
DotNetQuery.Any(cCode)1 when the code gives true for at least one item
DotNetQuery.All(cCode)1 when the code gives true for every item
DotNetQuery.Contains(xValue)1 when the source has the value xValue
DotNetQuery.First()the first item (an error when there is none)
DotNetQuery.FirstWhere(cCode)the first item for which the code gives true
DotNetQuery.Last()the last item (an error when there is none)
DotNetQuery.ElementAt(nIndex)the item at the zero-based position nIndex
DotNetQuery.Sum(cCode)Sum, Min, Max and Average are computed on the selected values (cCode = "" for the items themselves)
DotNetQuery.Average(cCode)the average of the selected values (cCode = "" for the items themselves)
DotNetQuery.Min(cCode)the smallest of the selected values (cCode = "" for the items themselves)
DotNetQuery.Max(cCode)the largest of the selected values (cCode = "" for the items themselves)
DotNetQuery.dnSelected(cCode)the values that the code selects (the items themselves for ""), as a Ring list: used by Sum, Average, Min and Max

Windows Forms helpers (gui.ring)#

FunctionDescription
uiForm(cTitle, nWidth, nHeight)A form with a client area of nWidth x nHeight, centered on the screen
uiLabel(oParent, cText, nX, nY, nWidth, nHeight)A label with a text, placed at (nX, nY) in the parent (a form or a container)
uiButton(oParent, cText, nX, nY, nWidth, nHeight, cClickCode)A button; cClickCode is Ring code run on click ("" for none)
uiTextBox(oParent, nX, nY, nWidth, nHeight)A one-line text box (uiMemo has several lines); read and write its Text
uiMemo(oParent, nX, nY, nWidth, nHeight)A text box with several lines, scroll bars, Enter and Tab keys, and no word wrap
uiCheckBox(oParent, cText, nX, nY, nWidth, nHeight, cClickCode)A check box; cClickCode is Ring code run on a click ("" for none); Checked is its state
uiListBox(oParent, nX, nY, nWidth, nHeight)A list box: Items.Add(text) adds an item, SelectedIndex is the chosen one (-1 for none)
uiComboBox(oParent, nX, nY, nWidth, aItems)A drop-down list that is filled from the Ring list aItems; the first item is chosen
uiPanel(oParent, nX, nY, nWidth, nHeight)A panel: a container for other controls (give it as the parent)
uiPictureBox(oParent, nX, nY, nWidth, nHeight)A picture box that shows a UiCanvas
uiTimer(nMilliseconds, cCode)A timer that runs Ring code every nMilliseconds (call .Start() / .Stop())
uiMenu(oForm, aMenus)A menu: uiMenu(oForm,[["File",[["Open","openFile()"],["-",""],["Exit","oForm.Close()"]]], ["Help",[["About","showAbout()"]]]])
uiGameKeys(oForm, cCode)every control reports the arrow keys, Space and Enter as KeyDown events of the form: uiGameKeys(oForm,"keyPressed(aDotNetArgs[2].KeyCode)"), called after the controls were added
uiInputKeys(oParent)Make the arrow keys (and Enter, Escape) arrive as KeyDown events on every control of the container
uiSendKeys(oForm, cKeys)Type keys into the form like a user does, for tests: "12{+}30{ENTER}", "{LEFT}", " " (SendKeys syntax: {LEFT} {RIGHT} {UP} {DOWN} {ENTER} {ESC} {BACKSPACE} {TAB} {DELETE}, {+} for a plus sign). The keys are posted to the focused control of THIS form, so they go through the real Windows Forms key processing and can never reach another program (SendKeys would).
uiRGB(nRed, nGreen, nBlue)A color from its red, green and blue parts (0 to 255)
uiColor(cName)A color from its name: uiColor("Red")
uiFont(cName, nSize, lBold)A font of a family and size (lBold = true for bold): uiFont("Segoe UI",12,false)
uiMessage(cText, cTitle)A message box (printed instead when running as a test)
uiAsk(cText, cTitle)Yes/No question: true for Yes (a test prints the question and answers yes)
uiOpenFileName(cTitle, cFilter)Open file dialog: returns the file name or ""
uiSaveFileName(cTitle, cFilter)Save file dialog: returns the file name or ""
uiNumber(nValue)A number as text without Ring's fixed decimals: 2.5 --> "2.5", 1e21 --> "1E+21" (uses .NET)
uiQuiet(oForm)A form that runs as a test is invisible and not in the taskbar (set the environment variable RINGDOTNET_SHOW to see it)
uiRun(oForm)Show the form and run the message loop. When running as a test (--selftest) the form closes itself after 30 seconds, and the checks in selftest/<program>.ring next to the program run once the form is shown (see dnLoadSelfTest); the result is printed at the end.
uiTest(oForm, cCode)The automatic part of an application: when running as a test, cCode runs once the form is shown and the form closes afterwards. The form must be in the global variable oForm (the code that closes it is oForm.Close()).
uiEnd()Print the result of a test run: "SELFTEST OK" or the failures (call after uiRun)
UiCanvas.init(oPictureBox)draw on a new bitmap of the size of the picture box, and show it there
UiCanvas.color(xColor)A color is a name ("Red"), "#RRGGBB" or a .NET Color object
UiCanvas.brush(xColor)a solid brush for a color (a name, "#RRGGBB" or a .NET Color); the brush of a name is made once
UiCanvas.pen(xColor, nPenWidth)a pen for a color and a width; the pen of a name and width is made once
UiCanvas.clear(xColor)fill the whole bitmap with a color
UiCanvas.fillRect(nX, nY, nW, nH, xColor)a filled rectangle with its corner at nX, nY
UiCanvas.drawRect(nX, nY, nW, nH, xColor)the outline of a rectangle with its corner at nX, nY
UiCanvas.fillCircle(nX, nY, nRadius, xColor)a filled circle around the center nX, nY
UiCanvas.drawCircle(nX, nY, nRadius, xColor)the outline of a circle around the center nX, nY
UiCanvas.fillEllipse(nX, nY, nW, nH, xColor)a filled ellipse in the rectangle that has its corner at nX, nY
UiCanvas.line(nX1, nY1, nX2, nY2, xColor, nPenWidth)a line from nX1, nY1 to nX2, nY2 with the pen width nPenWidth
UiCanvas.text(cText, nX, nY, xColor, nSize)text with the corner of its box at nX, nY; nSize is the font size (Segoe UI)
UiCanvas.setPixel(nX, nY, nRed, nGreen, nBlue)the color of one pixel from its red, green and blue parts (0 to 255). A Color has about 150 members, so its Ring object is slow to make (a few hundred microseconds): this keeps only the handle of the .NET Color, which takes about ten, enough for a picture of tens of thousands of pixels
UiCanvas.setPixels(nX, nY, nWidth, nHeight, cRgb)a rectangle of pixels from one text of 3 bytes for each pixel (red, green, blue: char(r) + char(g) + char(b) ...), row after row: the pixel nX, nY first, then nX + 1, nY ... A call from Ring into .NET costs several microseconds, so a picture made of tens of thousands of pixels is drawn with one call
UiCanvas.show()Refresh the picture box after drawing
UiCanvas.pixel(nX, nY)the color of the pixel at nX, nY as a hex text (ffRRGGBB), for tests
UiCanvas.close()release the graphics of the canvas

WPF helpers (wpf.ring)#

FunctionDescription
wpfWindow(cTitle, nWidth, nHeight)A window of nWidth x nHeight, centered on the screen
wpfXaml(cXaml)Build the objects of a XAML text: wpfXaml('<Button xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Content="Hi"/>')
wpfFind(oRoot, cName)The element called cName (x:Name / Name in XAML) inside oRoot
wpfBrush(cColor)A brush from a name or a code: wpfBrush("Red"), wpfBrush("#336699")
wpfColor(cColor)A color from a name or a code
wpfLabel(cText)A Label (a content control, the class WpfLabel) with a text
wpfText(cText)A TextBlock (a plain text) with a text
wpfButton(cText, cClickCode)A button; cClickCode is Ring code run when it is clicked
wpfQuiet(oWindow)A window that runs as a test is invisible and not in the taskbar (set the environment variable RINGDOTNET_SHOW to see it)
wpfRun(oWindow)Show the window and run the message loop until it is closed (modal; works more than once in a program). With --selftest the checks in selftest/<program>.ring next to the program run once the window is rendered (see dnLoadSelfTest), and the result is printed at the end.
wpfTest(oWindow, cCode)The automatic part of a program: when running as a test, cCode runs once the window is rendered and the window closes afterwards. The window must be in the global variable oWindow (the code that closes it is oWindow.Close()).
wpfEnd()Print the result of a test run ("SELFTEST OK" or "SELFTEST FAILED")
wpfPixel(oElement, nWidth, nHeight, nX, nY)The color of a pixel of a rendered element: "ffff0000" is opaque red (needs System.Drawing to read the picture)

Web server (web.ring)#

FunctionDescription
webJson(xValue)The response of a handler as JSON: a Ring list, or a list of [name, value] pairs for a JSON object
RingRequest.init(pHandle)a request that the server received; pHandle is its handle
RingRequest.method()the HTTP method: "GET", "POST"...
RingRequest.path()the path of the address, without the query string: "/api/echo"
RingRequest.queryString()the whole query string: "q=ring&page=2"
RingRequest.query(cName)a query string value: /search?q=ring --> query("q")
RingRequest.body()the body of the request as a text
RingRequest.header(cName)the value of the request header cName
RingRequest.form(cName)the value of the field cName of a posted form
RingRequest.setHeader(cName, cValue)add a header to the response
RingRequest.context()the ASP.NET HttpContext for everything else
RingRequest.respond(nStatus, cType, cBody)send the response: the status code, the content type and the text
WebServer.init(cUrl)start a Kestrel server that listens at cUrl: "http://localhost:5080" (port 0 chooses a free port)
WebServer.url()the real address (when the port was 0)
WebServer.route(cMethod, cPath, cHandler)handler: the name of a Ring function that receives a RingRequest and returns the response
WebServer.onGet(cPath, cHandler)the Ring function cHandler answers the GET requests of the path cPath
WebServer.onPost(cPath, cHandler)the Ring function cHandler answers the POST requests of the path cPath
WebServer.onPut(cPath, cHandler)the Ring function cHandler answers the PUT requests of the path cPath
WebServer.onDelete(cPath, cHandler)the Ring function cHandler answers the DELETE requests of the path cPath
WebServer.notFound(cHandler)the Ring function cHandler answers the requests that no route has
WebServer.serveOne(nMilliseconds)handle one request if one is waiting (waits up to nMilliseconds); true when a request was handled
WebServer.sendResponse(xResponse)send what a handler returned: a text (200, text/html) or [status, contentType, text]
WebServer.run()serve requests until stop() is called
WebServer.stop()make run() end (call it from a handler)
WebServer.close()stop serving and shut the server down

Entity Framework (data.ring)#

FunctionDescription
dbValue(aRow, cColumn)The value of a column in a row: dbValue(aRow,"Name")
dbWait(oTask)wait for a Task of the async methods and return its result
RingDatabase.init(cConnection, aSchema)cConnection is a SQLite connection string ("Data Source=people.db") or starts with the provider: "inmemory:shop", "sqlserver:Server=.;Database=x;...", "postgres:Host=...", "mysql:Server=..." (those need the EF Core package of the provider next to RingDotNet.Data.dll)
RingDatabase.insert(cTable, aValues)add a row, returns the key
RingDatabase.byKey(cTable, xKey)the row with the key, or "" when there is none
RingDatabase.all(cTable)all the rows of a table
RingDatabase.where(cTable, cCondition, aParameters)rows that match a SQL condition with {0} {1} ... parameters
RingDatabase.update(cTable, xKey, aValues)change the columns of the row with the key xKey: aValues = [[name, value], ...]
RingDatabase.remove(cTable, xKey)delete the row with the key xKey
RingDatabase.count(cTable)the number of rows of a table
RingDatabase.execute(cSql, aParameters)a SQL statement that changes data (parameters are {0} {1} ...): returns the number of rows
RingDatabase.scalar(cSql)the first value of a SQL query
RingDatabase.children(cParentTable, xKey, cChildTable)the rows of cChildTable that belong to the row cParentTable/xKey (the child table has a column with ["references","ParentTable"])
RingDatabase.parent(cChildTable, xKey, cParentTable)the row of cParentTable that the row cChildTable/xKey belongs to, or ""
RingDatabase.include(cTable, cRelatedTable)all the rows of cTable with their related rows: [[row, children or parent row], ...]
RingDatabase.query(cTable, aSpec)a query built as a LINQ expression tree (works with every provider): oDb.query("Customers",[ ["where",["and",["Age",">",30],["City","in",["Cairo","Giza"]]]], ["orderby",[["Age","desc"]]], ["skip",10], ["take",5], ["select",["Name","Age"]] ]) conditions: [column, op, value] with op = != < <= > >= contains startswith endswith in isnull notnull; ["and",c1,c2,...] ["or",c1,c2,...] ["not",c]
RingDatabase.aggregate(cTable, cFunction, cColumn, aCondition)count, sum, min, max or average of a column for the rows that match a condition ([] = all rows)
RingDatabase.countWhere(cTable, aCondition)the number of rows that match the condition aCondition
RingDatabase.sum(cTable, cColumn, aCondition)the sum of a column for the rows that match the condition ([] = all rows)
RingDatabase.min(cTable, cColumn, aCondition)the smallest value of a column for the rows that match the condition ([] = all rows)
RingDatabase.max(cTable, cColumn, aCondition)the largest value of a column for the rows that match the condition ([] = all rows)
RingDatabase.average(cTable, cColumn, aCondition)the average of a column for the rows that match the condition ([] = all rows)
RingDatabase.groupCount(cTable, cColumn, aCondition)[[value, count], ...] for each value of a column
RingDatabase.sqlRows(cSql, aParameters)the rows of any SELECT (any columns, joins, groups) as lists of [column, value]: sqlRows("SELECT City, COUNT(*) AS N FROM Customers GROUP BY City",[])
RingDatabase.onSaving(oCallback)hooks: Ring functions (dnCallback("name")) that run when changes are saved or SQL is executed; the function gets the list of arguments oDb.onSaving(dnCallback("checkChanges")) # func checkChanges aArgs: aArgs[1] = [[table, state, row], ...]; return a text to cancel the save oDb.onSaved(dnCallback("afterSave")) # aArgs[1] = the number of rows oDb.onLog(dnCallback("showSql")) # aArgs[1] = the SQL text
RingDatabase.onSaved(oCallback)hook: the callback runs after the changes were saved; aArgs[1] = the number of rows
RingDatabase.onLog(oCallback)hook: the callback gets every SQL text that EF Core runs
RingDatabase.pendingChanges()the changes waiting to be saved (with autoSave(false)): [[table, "Added"|"Modified"|"Deleted", row], ...]
RingDatabase.migrate()migrations: bring an existing database in line with the model (creates the missing tables, columns and indexes); returns the list of changes, for example ["add column Users.Email"]
RingDatabase.apply(cName, cSql)a named change (SQL) that is applied once: returns 1 when it was applied now, 0 when it had been applied before
RingDatabase.applied()the names of the applied changes
RingDatabase.begin()transactions: begin() ... commit() or rollback(); an error in commit() undoes everything
RingDatabase.commit()save the changes of the transaction that begin() started
RingDatabase.rollback()undo the changes of the transaction that begin() started
RingDatabase.inTransaction()1 while a transaction that begin() started is open
RingDatabase.insertAsync(cTable, aValues)async versions return a .NET Task: dbWait(oTask) waits and returns the result
RingDatabase.allAsync(cTable)async all(): a .NET Task
RingDatabase.whereAsync(cTable, cCondition, aParameters)async where(): a .NET Task
RingDatabase.countAsync(cTable)async count(): a .NET Task
RingDatabase.saveAsync()async save(): a .NET Task
RingDatabase.autoSave(lAuto)autoSave(false): changes are written when save() is called (one batch)
RingDatabase.save()write the pending changes (after autoSave(false))
RingDatabase.discard()forget the changes that were not saved (a failed save does this by itself)
RingDatabase.columnInfo(cTable, cColumn)a column of the model: [["name",..],["type",..],["key",..],["nullable",..],["required",..],["unique",..],["index",..],["maxlength",..]]
RingDatabase.context()the EF Core DbContext (a DotNetObject) for everything else
RingDatabase.close()release the database context and the connection
RingEntityDb.init(cConnection, aSchema)open the database; aSchema describes the tables, which become .NET classes (the same schema lists as RingDatabase)
RingEntityDb.newEntity(cTable)a new entity (a DotNetObject of the generated class)
RingEntityDb.entityType(cTable)the .NET class (System.Type) of a table
RingEntityDb.properties(cTable)the names of the properties of a table (columns, then navigations)
RingEntityDb.add(oEntity)add an entity (with the entities it refers to); returns the key
RingEntityDb.remove(oEntity)delete an entity
RingEntityDb.find(cTable, xKey)the entity with the key (a list for a composite key), or ""
RingEntityDb.query(cTable, aSpec)the entities that match a query: same specification as RingDatabase.query, plus ["include",["Navigation","Other.Nested"]]
RingEntityDb.all(cTable)all the entities of a table
RingEntityDb.count(cTable, aCondition)the number of entities of a table that match the condition aCondition ([] = all)
RingEntityDb.getValue(oEntity, cProperty)read / write a property of an entity (dates are texts, bytes are hex texts)
RingEntityDb.setValue(oEntity, cProperty, xValue)set a property of an entity
RingEntityDb.toRow(oEntity)the columns of an entity as [[name, value], ...]; fill() sets columns from such a list
RingEntityDb.fill(oEntity, aValues)set several columns of an entity from [[name, value], ...]
RingEntityDb.save()write the changes of the tracked entities
RingEntityDb.autoSave(lAuto)autoSave(false): the changes are written when save() is called
RingEntityDb.discard()forget the changes that were not saved
RingEntityDb.begin()start a transaction
RingEntityDb.commit()save the changes of the transaction
RingEntityDb.rollback()undo the changes of the transaction
RingEntityDb.context()the EF Core DbContext (a DotNetObject) for everything else
RingEntityDb.close()release the database context and the connection

Generated classes#

The wrapper classes are generated; there are two files for each namespace in libraries/dotnetlib/generated/ (a loader and the classes). The members of a class are the members of the .NET class (see the .NET documentation), named by the rules. To see the Ring name of a method, open its class file or call dnDescribe("Namespace.Type").

Where to go next#

RingDotNet — use .NET classes and methods from Ring programs. Screenshots and output on these pages come from the real samples.