Current filter:
                                You should refresh the page.


                                In this example, we will create a WCF IDataStore service that will be used by our client (Console Application) as a data layer. Instead of the direct connection to the database, our client will connect to a remote service, which is way more secure and thus important in many enterprise scenarios as database connection settings are not exposed to the client.

                                Steps to implement

                                1. Create a new WCF Service Application project and add references to the DevExpress.Data and DevExpress.Xpo assemblies and remove files with auto-generated interfaces for the service.

                                2. Modify the service class as shown in the Service1 file. This service initializes a connection provider and stores it in the static DataStore property, which is then used by the base DataStoreService class.

                                3. Change some binding properties as shown in the example's web.config file. At this stage, the service part is ready to work and we need to implement a client to consume data from our data store service (for demonstration purposes, we will create a Console Application).

                                4. Add the Console Application into the existing solution.

                                5. Add a new code file for a Customer class using the DevExpress v1X.X ORM Persistent Object item template. See a code of Customer class in the ConsoleApplication\Customer code file.

                                6. Pass the address of our service into the GetDataLayer method of the XpoDefault class. For this, modify the Main method of the Console Application as shown in the ConsoleApplication\Program code file. Please note that the port number in the connection string may be different. You can check it in the properties of the service project in the Solution Explorer:

                                As a result, we will see the following output:

                                Important notes
                                If you are using an XAF client, then in the simplest case, you can just set the XafApplication.ConnectionString to the address of your data store service (http://localhost:55777/Service1.svc). Refer to the Connect an XAF Application to a Database Provider help article for more details.


                                1. If WCF throws the "Request Entity Too Large" error, you can apply a standard solution from StackOverFlow:

                                2. If WCF throws the "The maximum string content length quota (8192) has been exceeded while reading XML data. " error, you can extend bindings in the following manner as per

                                <bindings> <basicHttpBinding> <binding name="ServicesBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" > <readerQuotas maxDepth="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"/> </binding> </basicHttpBinding> </bindings>

                                See Also:
                                How to use XPO with a Web Service
                                Transferring Data via WCF Services
                                How to connect to a remote data service from a Silverlight application

                                How to create a data caching service that helps improve performance in distributed applications

                                How to implement a distributed object layer service working via WCF

                                How to connect to remote data store and configure WCF end point programmatically

                                Files to look at:

                                Program.cs (VB: Program.vb)
                                Service1.svc.cs (VB: Service1.svc.vb)
                                Web.config (VB: Web.config)