Current filter:
                                You should refresh the page.

                                Scenario:
                                In the How to connect to a remote data service instead of using a direct database connection example we described how to connect to the WCF service via console application.
                                If you want to take advantages of XPO data caching using this solution, the only difference is in using the ICachedDataStore interface and the CachedDataStoreService base service class that implements this interface.

                                Steps to implement
                                1. Create a data service and console applications as described in the How to connect to a remote data service instead of using a direct database connection example.
                                2. Modify the service class as shown in the WCFService1\Service1 code file: use the CachedDataStoreService as base class, create a connection provide and data store.
                                3. Modify the web.configfile as shown in the WCFService1\web.config file.

                                There is no need to modify the client part since the service name has not been changed, and in addition, the “data caching domain” of our service is automatically detected by XPO.
                                It is easy to configure which tables should be cached and which ones shouldn't using the following code from the Service1 code file:

                                [C#]
                                DataCacheRoot dataCacheRoot = new DataCacheRoot(dataStore) dataCacheRoot.Configure(new DataCacheConfiguration(DataCacheConfigurationCaching.InList, "Customer") MainDataStore = dataCacheRoot;
                                [VB.NET]
                                Dim dataCacheRoot As New DataCacheRoot(dataStore) dataCacheRoot.Configure(New DataCacheConfiguration(DataCacheConfigurationCaching.InList, "Customer")) MainDataStore = dataCacheRoot

                                This approach is useful for tables, which are frequently changed.

                                4. Create a data caching service based on the SqlDependency feature of the MS SQL Server. This approach is demonstrated in the WCFService2.Service1.xx file.

                                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.

                                Troubleshooting

                                1. If WCF throws the "Entity is too large" error, you can apply a standard solution from StackOverFlow: http://stackoverflow.com/questions/10122957/
                                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:
                                [XML]
                                <bindings> <basicHttpBinding> <binding name="ServicesBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" > <readerQuotas maxDepth="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"/> </binding> </basicHttpBinding> </bindings>

                                See The maximum string content length quota (8192) has been exceeded while reading XML data

                                See also:
                                How to connect to a remote data service instead of using a direct database connection
                                How to implement a distributed object layer service working via WCF
                                How to connect to a remote data service from a Silverlight application

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

                                Files to look at:

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