xsharp.eu • privates DataSession
Page 1 of 1

privates DataSession

Posted: Mon Feb 03, 2025 6:39 pm
by jpmoschi
Good morning guys, I'm reviewing XSharp and I enjoy the evolution when I recognize that the equivalent of the FoxPro SET command has been incorporated, a useful debugging object to see the different "dbf aliases" open in different data sessions.

The question arises for me: what is the approach to managing different private DataSessions in XSharp that try to emulate VFP Data Sessions?

In other words, in FoxPro, forms (Class Form, etc.) have the DataSession property that determines the visibility of open aliases. Can XSHARP understand the concept of private data sessions linked to the life of a form or some equivalent mechanism?

Does anyone on the forum have some code examples to analyze and understand it?

thank you
Juan
Captura.JPG

Re: privates DataSession

Posted: Tue Feb 04, 2025 2:40 am
by xinjie
Hi, Juan

You'll notice ADO.NET if you think about data binding further.
A DataSet is very similar to a DataSession.

Re: privates DataSession

Posted: Tue Feb 04, 2025 9:29 am
by robert
Juan,
We indeed support the concept of a DataSession. There is a DataSession class (see https://www.xsharp.eu/runtimehelp/html/ ... ession.htm)
It has the list of open workareas/cursors
A form can create a new datasession :

oDataSession := DataSession{"DatasessionName"}

This object will be automatically added to the list of open datasessions.
The Datasession object has a name and an ID. It also saves the thread in which it was created.
When the thread exits, then the session will be closed automatically (and the files will be closed to).

The RuntimeState has a method SetDataSession() that you can use to set the current active datasession.

Please note that for index expressions to be properly evaluated by the Macro compiler, you will have to make sure that the DataSession that the file is opened in is the current active Datasession in the runtime state

We are still working on automatically opening and restoring the datasession for a form.

Robert