Current filter:
                                You should refresh the page.
                                Support Center

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0

                                Implemented:


                                Additional information:

                                The following code is now added by the Solution Wizard to the Global.asax.cs file for XPO-based applications (the behavior of existing applications is not changed):


                                [C#]
                                protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {     CreateXPObjectSpaceProvider(args.ConnectionString, args);     args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null)); } private void CreateXPObjectSpaceProvider(string connectionString, CreateCustomObjectSpaceProviderEventArgs e) {     System.Web.HttpApplicationState application = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null;     IXpoDataStoreProvider dataStoreProvider = null;     if(application != null && application["DataStoreProvider"] != null) {         dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider;         e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);     }     else {         if(!String.IsNullOrEmpty(connectionString)) {             connectionString = DevExpress.Xpo.XpoDefault.GetConnectionPoolString(connectionString);             dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true);         }         else if(e.Connection != null) {             dataStoreProvider = new ConnectionDataStoreProvider(e.Connection);         }         if (application != null) {             application["DataStoreProvider"] = dataStoreProvider;         }         e.ObjectSpaceProvider = new XPObjectSpaceProvider(dataStoreProvider, true);     } }

                                A single IXpoDataStoreProvider and IDataStore are created per each database, and they are shared by all users. Note that the true value is passed to the useCachedDataStore parameter of the ConnectionStringDataStoreProvider constructor. This parameter specifies if the cached IDataStore instance is used or a new IDataStore instance is created per each CreateWorkingStore method call.

                                When Object Space Providers are created in the overridden CreateDefaultObjectSpaceProvider method, providers (and their connections) are disposed of when the application is disposed of (e.g. on re-logon). When providers are created using the CreateCustomObjectSpaceProvider event, providers and their connections are disposed of together with their application too. Set the event's CreateCustomObjectSpaceProviderEventArgs.IsObjectSpaceProviderOwner parameter to false to cancel dispose of providers together with the application in this scenario:


                                [C#]
                                private void Instance_CreateCustomObjectSpaceProvider(object sender, CreateCustomObjectSpaceProviderEventArgs e) { IXpoDataStoreProvider dataStoreProvider = null; if(Application["DataStoreProvider"] != null) { dataStoreProvider = Application["DataStoreProvider"] as IXpoDataStoreProvider; e.ObjectSpaceProvider = new SecuredObjectSpaceProvider((ISelectDataSecurityProvider)WebApplication.Instance.Security, dataStoreProvider, true); } else { if(!String.IsNullOrEmpty(e.ConnectionString)) { string connectionString = DevExpress.Xpo.XpoDefault.GetConnectionPoolString(e.ConnectionString); dataStoreProvider = new ConnectionStringDataStoreProvider(connectionString, true); } else if (e.Connection != null){ dataStoreProvider = new ConnectionDataStoreProvider(e.Connection); } Application["DataStoreProvider"] = dataStoreProvider; e.ObjectSpaceProvider = new SecuredObjectSpaceProvider((ISelectDataSecurityProvider)WebApplication.Instance.Security, dataStoreProvider, true); } e.IsObjectSpaceProviderOwner = false; }
                                Show all comments
                                • Gustavo Marzioni 11.16.2015

                                  May I use this modifications in 15.1.8?

                                • Konstantin B (DevExpress) 11.16.2015
                                  Gustavo, this functionality is not available in 15.1.8. Please wait till the major update version 15.2 is released.
                                • Nikolay Bobrovskiy 1 12.03.2015

                                  Why is "e.IsObjectSpaceProviderOwner = true" placed in "else" block only?

                                • Alex Gn (DevExpress) 12.04.2015

                                  Hello Nikolay,
                                  Thank you for your comment. I have corrected the original answer.

                                • MohammedFarooq 08.28.2017
                                  Hi there,

                                  My project uses SecuredObjectSpaceProvider as stated in article How to: Hide the 'Protected Content' Rows in a List View Using the Security System Integrated Mode, how shall i implement the same logic in my project that has gone through several updates of XAF Versions, my intitial application version was V12.x and now i am V17.1.5. In order to implement the Initialization of one XPO data layer per one global HttpApplication what changes shall i make.

                                  Currently my code is as follows:

                                  [C#]
                                  //To hide protected contents from being shown to non authorized user. protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) { args.ObjectSpaceProvider = new SecuredObjectSpaceProvider((SecurityStrategyComplex)Security, args.ConnectionString, args.Connection); ((SecuredObjectSpaceProvider)args.ObjectSpaceProvider).AllowICommandChannelDoWithSecurityContext = true; args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null)); }

                                • Alex Gn (DevExpress) 08.28.2017

                                  Hello,

                                  The CreateDefaultObjectSpaceProvider method should be modified as follows:

                                  [C#]
                                  protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) { SecuredObjectSpaceProvider provider = new SecuredObjectSpaceProvider((ISelectDataSecurityProvider)Security, GetDataStoreProvider(args.ConnectionString, args.Connection)); provider.AllowICommandChannelDoWithSecurityContext = true; args.ObjectSpaceProviders.Add(provider); } private IXpoDataStoreProvider GetDataStoreProvider(string connectionString, System.Data.IDbConnection connection) { System.Web.HttpApplicationState application = (System.Web.HttpContext.Current != null) ? System.Web.HttpContext.Current.Application : null; IXpoDataStoreProvider dataStoreProvider = null; if (application != null && application["DataStoreProvider"] != null) { dataStoreProvider = application["DataStoreProvider"] as IXpoDataStoreProvider; } else { dataStoreProvider = XPObjectSpaceProvider.GetDataStoreProvider(connectionString, connection, true); if (application != null) { application["DataStoreProvider"] = dataStoreProvider; } } return dataStoreProvider; }

                                  Let me know if you need any further assistance.

                                • MohammedFarooq 08.28.2017
                                  Many thanks Alex for your quick response and solution. 
                                • Alex Gn (DevExpress) 08.28.2017
                                  You are always welcome!

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners