Ticket S170964
Visible to All Users

XpoDataServiceV3 - Provide a virtual method to create a custom Session

created 12 years ago

Created per ObjectSpace is null when using oData/XpoDataServiceV3.

C#
internal UnitOfWork GetSession() { UnitOfWork uow; if (!SessionCache.TryGetValue(this, out uow)) { ResolveSessionEventArgs args = new ResolveSessionEventArgs(); OnResolveSession(args); if(args.Session != null) { uow = args.Session.Session; } if (uow == null){ uow = new UnitOfWork(Context.ObjectLayer); } SessionCache.Add(this, uow); } return uow; } protected virtual UnitOfWork GetSessionCore() { return new UnitOfWork(Context.ObjectLayer); } protected virtual void OnResolveSession(ResolveSessionEventArgs args) { if(Events[EventResolveSession] != null) ((ResolveSessionEventHandler)Events[EventResolveSession])(this, args); } static readonly object EventResolveSession = new object(); public event ResolveSessionEventHandler ResolveSession { add { Events.AddHandler(EventResolveSession, value); } remove { Events.RemoveHandler(EventResolveSession, value); } }

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

We have implemented the functionality described in this ticket. It will be included in our next update(s).

Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

Additional information:

Starting with version 12.2.8, the XpoDataServiceV3 class will provide a virtual GetSessionCore method. For instance, you can override it as follows if you are using Domain Components (DC):

C#
protected override UnitOfWork GetSessionCore() { if (objectSpaceProvider != null) { XPObjectSpace os = (XPObjectSpace)objectSpaceProvider.CreateObjectSpace(); return (UnitOfWork)os.Session; } return base.GetSessionCore(); }

Refer to the ObjectSpace is null when using oData/XpoDataServiceV3 ticket for a complete sample project.
Thanks,
Dennis

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.