I'm use the provider the data via WCF Service.
At the Server, I'm Use the DataStoreService and run in windows services. database server is MSSQL2008.
at the Client, I'm use the DataStoreClient:
DataStoreClient c = new DataStoreClient(ntBinding, new EndpointAddress("net.tcp://127.0.0.1:8991/MindSoft.CoreService/4D23558A37D64000B11BC8D30564937D/DataStoreContractService"));
XpoDefault.DataLayer = new SimpleDataLayer©;
Session s = new Session();
When I use the s.ExecuteQuery("Select * From Customer") methon. throw a Exception
"Command 'DevExpress.Xpo.Helpers.CommandChannelHelper.ExecuteQuerySQL' is not supported by DevExpress.Xpo.DB.MSSqlConnectionProvider"
Why have the Exception…
And I have any way to excute sql query via DataStoreService and DataStoreClient?
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.
Hello Qu,
Your results look rather strange. We did not face this issue in our tests. Would you please provide us with a small sample project reproducing this issue? We will research it and do our best to find a solution.
Thanks,
Michael.
I write a example.
the host project is a wcf host use DataStoreService
the Client Project is a wcf client use DataStoreClient
Hello Qu,
Thank you for your project. This exception occurs because the connection provider you are creating in your DataStoreContractService is not set as a command channel. Since the DataStoreService.commandChannel field is declared as readonly, it cannot be assigned later. You must pass the provider in the base DataStoreService constructor argument.
Attached is a modified project. Please also refer to the XPO – 11.1 Sneak Peek - WCF services for IDataStore article.
Thanks,
Michael.
thanks you modify…and I understand the DataStoreService's usage
But:
"the DataStoreService.commandChannel field is declared as readonly", I see the DataStoreService 's Code…
protected readonly ICommandChannel commandChannel;
And Can you tell me why the commandChannel is Readonly…and I will change to read/write…then will bring about some wrong…
Hi Qu,
It seems that we forgot to mark the "provider" field as read-only. These fields are read-only because they are not meant to be changed after the service creation. You must pass a provider instance in the base service constructor argument.
Thanks,
Michael.
I override the Do methon.
like:
public override DevExpress.Xpo.DB.OperationResult<object> Do(string command, object args)
{
ICommandChannel tmpcmdchannel = provider as ICommandChannel;
if (tmpcmdchannel == null)
{
if (provider == null)
{
return new OperationResult<object>(ServiceException.NotSupported, string.Format(CommandChannelHelper.Message_CommandIsNotSupported, command));
}
else
{
return new OperationResult<object>(ServiceException.NotSupported, string.Format(CommandChannelHelper.Message_CommandIsNotSupportedEx, command, provider.GetType().FullName));
}
}
return Execute<object>(delegate() { return tmpcmdchannel.Do(command, args); });
}
Becase I Find the tmpcmdchannel is Only use at Do methon…and the Do methon can be override
It's regular work. the Client less then 10 PCs…
This Code have any question when clien is increase?
Hi Qu,
I am afraid I do not understand your question. Moreover, it is unclear why you do not want to pass a provider instance in constructor arguments.
Thanks,
Michael.
thank you for your reply.
I not pass a provider instance in constructor arguments
Because I'll connect different database for each different baseaddress.
for example:
the baseaddress:net.tcp://serverIP:port/MindSoft/DB1/DataStoreContractService will connection the database "DB1"
the baseaddress:net.tcp://serverIP:port/MindSoft/DB2/DataStoreContractService will connection the database "DB2"
Then the provider is not fixed at run time.
I will get the AccountID pass OperationContext.Current.Host.BaseAddresses[0] methon at the dataservice constructor and create different provider for the client connect different database.
I don't know if there is a better way is recommended??
Hi Qu,
Thank you for the clarification. We couldn't find an immediate solution for this scenario. Please bear with us. We will inform you as soon as an answer is found.
Thanks,
Michael.
Hi Qu,
I recommend that you implement this functionality as follows. Create a custom connection provider (IDataStore) with a dictionary of nested providers for every database you want to connect, and implement IDataStore and ICommandChannel methods to delegate operations to an appropriate nested provider, selected from the dictionary.
Thanks,
Michael.