Hello
I'm consuming a oData service which inherits your XpoDataServiceV3, for Domain Components.
For retrieving data, it is doing good. But for updates, I noticed that the objectSpace parameter is null within the OnSaving() event.
And I need the objectSpace to enforce some logic on the entities.
This is how I initialize the service:
----------------------------------
static IDataLayer CreateDataLayer()
{
XpoTypesInfoHelper.ForceInitialize();
var typesInfo = XpoTypesInfoHelper.GetTypesInfo();
var xpoTypeInfoSource = XpoTypesInfoHelper.GetXpoTypeInfoSource();
Type type = null;
type = typeof(Survey); typesInfo.RegisterEntity(type.Name, type);
typesInfo.GenerateEntities();
var connectionString = "Pooling=true;Data Source=.;User Id=***;Password=*****;Initial Catalog=****";
var dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString);
var objectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, typesInfo, xpoTypeInfoSource);
var dict = objectSpaceProvider.XPDictionary;
var store = XpoDefault.GetConnectionProvider(connectionString, DevExpress.Xpo.DB.AutoCreateOption.SchemaAlreadyExists);
var dataLayer = new ThreadSafeDataLayer(dict, store);
XpoDefault.DataLayer = dataLayer;
return dataLayer;
}
----------------------------------
Now, the domain component's event:
----------------------------------
public void OnSaving(Survey instance, IObjectSpace objectSpace)
{
var space = objectSpace; //<—objectSpace is null
//…
//…
//…
}
----------------------------------
I've tried to use XpoDefault.Session in the OnSaving() event, but it brings an exception saying that the object belongs to another session.
I've even tried "DevExpress.ExpressApp.Xpo.XPObjectSpace.FindObjectSpaceByObject(instance)", but it also returns null.
Finally, is it possible to retrieve the objectSpace (inside the Domain Component logic), from an object that started in a XpoDataServiceV3?
Hello Sidney,
As I wrote you earlier in your other ticket, we have not yet tested this particular scenario.
In any event, we will be glad to research your project (please attach it here) and advise what can be done to overcome this behavior. Maybe a tiny change is required in our code to support this.
Hello Dennis.
Here is the sample.
The project is a miscelania of Xaf + Dxtreme oData + Dxtreme Multichannel, in this order.
Use the Xaf Winforms to compile the database, as I have tested here.
If you need more info, please advise me.
Just to document the steps:
After all is compiled, and the DataService1 is started and the multichannel application is pointing to the DataService1 url, try to add a new Survey object by the DxtremeApplication1.
When you click the button "Save", you will receive the message "HERE! ObjectSpace is null"
Look at "XafObjectSpaceNull.Module.BusinessObjects.Survey" class to see the code.
Hello Sidney,
Thanks for the sample. I will research it and let you know my results. It will require more time, because as I wrote above this scenario is not currently supported.