Current filter:
                                You should refresh the page.
                                  • This article describes how to connect an existing XAF Mobile application to the new ASP.NET Core Data Service shipped in v18.2. Use this service to get the following benefits:
                                    - Non-persistent objects support;
                                    ContainsOperator and aggregate functions in ListView filters (Free Joins are not yet supported);
                                    - Displaying List Views of non-associated collections;
                                    - Filtering lookups by an arbitrary (non-associated) DataSourceProperty.

                                    If you use these features in your Mobile application, check the "Known behavior" section at the end of this article. 


                                    Your feedback counts!

                                    This feature is still in active development and our API may be changed in future release cycles. If you are an active DevExpress Universal subscriber and would like to test these features prior to its official release, please email our support team at support@devexpress.com, leave a comment to this article or rather, create a separate private ticket in the Support Center. With that, we can verify your account and provide you with a v18.2 preview installation privately.

                                    If you are using a trial and want to use these features today, you can purchase a DevExpress Universal license online (this will give you access to early builds such as this CTP). If you own a non-Universal subscription and are ready to upgrade, email us at clientservices@devexpress.com for preferential upgrade pricing.

                                    By providing early build access, we hope to find out whether our new features and solutions address your requirements and issues. Your testing efforts and your feedback help us deliver the best possible final implementation. We have described other benefits of this cooperation in this post.

                                    In advance, thank you very much for your help!

                                    Prerequisites

                                    XAF v18.2.4+ and Visual Studio 2017+ with .NET Framework 4.6.1+ are required.
                                    XPO classes and non-persistent POCO are supported for data access. Entity Framework (EF) and Domain Components (DC) interfaces are not supported.

                                    Attached files
                                    The DataServiceExample.zip archive contains the following folders:
                                    DemoApplication.Spa with the Data Service that can be attached to your XAF Mobile application;
                                    MobileDemoApplication with a sample XAF Mobile application connected to this service.

                                    Steps to implement
                                    1. Data Service configuration.
                                    1.1 Include the data service project (DemoApplication.Spa in our example) into your XAF solution. Update its references using the Project Converter and call the Restore NuGet Packages command if necessary.
                                    1.2 Add references to your XAF Application’s assemblies to the service project. Typically, these are:
                                    YourSolutionName.Module 
                                    YourSolutionName.Module.Mobile 
                                    YourSolutionName.Mobile 

                                    1.3 Replace the YourMobileApplicationClassName placeholder in the DemoApplication.Spa\Startup.xx file with the name of your MobileApplication descendant from the Mobile project.
                                    1.4 Configure the ConnectionString parameter of the DemoApplication.Spa\app.config file to specify the service’s database connection. Insert the connection string of your Mobile application there.

                                    2. Security setup.
                                    2.1 If your Mobile application does not use the Security module, remove the following lines of code from the DemoApplication.Spa\Startup.xx file:

                                    [C#]
                                    SetUpAuthentication(services); ... app.UseMiddleware<RequestSecurityMiddleware>();
                                    [VB.NET]
                                    SetUpAuthentication(services) ... app.UseMiddleware(Of RequestSecurityMiddleware)()

                                     

                                    2.2 If your Mobile application uses Security, change its authentication type to AuthenticationMixed. Here is an example of how to do this in the MobileApplication.xx file:

                                    [C#]
                                    using DevExpress.ExpressApp.Security; using DevExpress.Persistent.BaseImpl.PermissionPolicy; public partial class MobileDemoApplicationMobileApplication : MobileApplication { public MobileDemoApplicationMobileApplication() { ... AuthenticationMixed authenticationMixed = new AuthenticationMixed(); authenticationMixed.LogonParametersType = typeof(AuthenticationStandardLogonParameters); authenticationMixed.IsSupportChangePassword = true; authenticationMixed.AddAuthenticationStandardProvider(typeof(PermissionPolicyUser)); authenticationMixed.AddIdentityAuthenticationProvider(typeof(PermissionPolicyUser)); ((SecurityStrategyBase)Security).Authentication = authenticationMixed; }
                                    [VB.NET]
                                    Imports DevExpress.ExpressApp.Security Imports DevExpress.Persistent.BaseImpl.PermissionPolicy Partial Public Class MobileDemoApplicationMobileApplication Inherits MobileApplication Public Sub New() ... Dim _AuthenticationMixed As New AuthenticationMixed() _AuthenticationMixed.LogonParametersType = GetType(AuthenticationStandardLogonParameters) _AuthenticationMixed.IsSupportChangePassword = True _AuthenticationMixed.AddAuthenticationStandardProvider(GetType(PermissionPolicyUser)) _AuthenticationMixed.AddIdentityAuthenticationProvider(GetType(PermissionPolicyUser)) CType(Security, SecurityStrategyBase).Authentication = _AuthenticationMixed End Sub

                                     

                                    AuthenticationMixed is required to use multiple authentication methods in the same application. The new Data Service uses AuthenticationStandardProvider for the initial logon and IdentityAuthenticationProvider for user request authentication. 
                                    The Mobile application modified in this manner remains compatible with the former Data Service. 

                                    3. Check how the Data Service starts.
                                    Launch the service project (DemoApplication.Spa). If everything is configured correctly, you will see the following result:

                                    With Security


                                    Without Security


                                    4. Connect your application to the Data Service.
                                    Add the following key to your Mobile application’s web.config:

                                    [XML]
                                    <appSettings> ... <add key="DataServiceUrl" value="http://localhost:51583/api"/> </appSettings>

                                     

                                    The service’s port can be copied from the project's settings (launchSettings.json) or from the browser, as shown in the previous step.

                                    5. Copy the YourSolutionName.Mobile\Model.xafml file to the service's output directory (e.g., DemoApplication.Spa\bin\Debug\net461).
                                    You can do this by adding this file to the DemoApplication.Spa project and setting its Copy to Output Directory parameter to Copy Always. Note that the service's Model.xafml file should always contain the most recent version of the YourSolutionName.Mobile\Model.xafml file.
                                    In the attached example, the file is copied using the following post-build event command line in the MobileDemoApplication.Mobile project:
                                    copy /Y "$(SolutionDir)\$(ProjectName)\Model.xafml" "$(SolutionDir)\DemoApplication.Spa

                                    6. Run the application.
                                    With this configuration, it is necessary to start the Mobile application (YourSolutionName.Mobile) and the Data Service (DemoApplication.Spa) together. To do this, configure the Multiple startup projects parameter in the Visual Studio solution settings as follows.



                                    Alternatively, launch the Data Service and then the Mobile application manually.

                                    Notes
                                    This article shows minimum steps required to preview and test the new Data Service with existing XAF Mobile applications. We do not recommend that you use it in production at the current stage. For simplicity, the example has the following specificities:
                                    1. By default, Mobile applications use the System.Web.HttpContext.Current.Application object to cache XpoDataStoreProvider in the GetDataStoreProvider method. The new service is based on ASP.NET Core and cannot use this caching. So, a new SQL connection will be created for each request.
                                    2. CORS is disabled in the attached Data Service through the following settings: AllowAnyOriginAllowCredentialsAllowAnyMethodAllowAnyHeader. This allows launching the Data Service and the Mobile application with different ports without additional configuration.
                                    3. The resulting project will use the YourSolutionName.Mobile project's connection string to build the client application. So, connection parameters should also be specified in YourSolutionName.Mobile\Web.config.

                                    Known behavior

                                    1. To show a non-persistent object's Detail View from a ListView, handle the NonPersistentObjectSpace.ObjectByKeyGetting event.
                                    2. Custom members created dynamically in code or in the Model Editor are not supported out of the box. See a possible workaround in the following ticket: Mobile - Can I use custom members with the ASP.NET Core Data Service?
                                    3. When a non-associated collection property returns a collection whose records are already loaded (e.g., List<T>), filters from the ListView.CollectionSource.Criteria property are not applied to it.

                                • Nate Laff 10.25.2018
                                  Here's what would be super rad. If this data service could talk to some kind of remoting service on another PC. For example, let me host the ASP.NET Core data service on my web server, meanwhile, each of my users have their own database on their PC. Requests could contain info about which connection its headed towards, and send to some remoting service on that end (so I don't need to open up port forwarding).

                                  This would be an extreme help. I feel like you're getting pretty close to making this a reality.
                                • Petr Zima 02.27.2019
                                  Hello,

                                  I tried this example at 18.2.4 and it worked verry well. Now I upgraded to latest version (18.2.6) and this example is no more functional. Spa project gets 500 error without any other informations. Can you please validate if this demo is working with version 18.2.6?

                                  (btw I upgraded Spa project dependencies with nuget system to latest version as well)

                                  Thank you for your time.
                                • Anatol (DevExpress Support) 02.27.2019
                                  Hello Petr,

                                  I checked this project with version 18.2.6. I did the following steps:
                                  1. Updated the project's references using the Project Converter tool.
                                  2. Updated the DevExtreme.AspNet.Data NuGet package to version 2.1.1 in the NuGet Package Manager.
                                  3. Restored the project's NuGet Packages.

                                  This was sufficient to run the project. I have also attached updated projects to this article. If this does not help, please create a separate ticket and provide a sample project and error details.

                                • Jacek Kosiński 04.26.2019
                                  is possible to use SPA UI data serice with non Xaf application ? How can i do it ?
                                • Anatol (DevExpress Support) 04.29.2019
                                  Yes, you can reuse certain parts of this Data Service. Please see additional information in the following ticket: How to use the new ASP.NET Core Data Service for SPA UI to query data from external clients.

                                0 Solutions

                                Creation Date Importance Sort by