I have a method in the doamin service that expects a Parameter.
The RadDomainDatasource does not find it and throws an expection.
"Could not find a matching query method on the DomainContext."
I set the Parameter in the code before loading the data.
The generic Ria DomainDataSource work with the same service and method.
Help anyone?
Thanks in advance.
<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance ds:EMSalesDomainContext, CreateList=true}" Height="0" Name="ProductsDataSource" QueryName="GetProductGroupsForCustomerQuery" >
<riaControls:DomainDataSource.DomainContext>
<ds:EMSalesDomainContext/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<telerik:RadDomainDataSource x:Name="ProductsDataSource2"
AutoLoad="False" QueryName="GetProductGroupsForCustomerQuery" > (This is not found)
<telerik:RadDomainDataSource.DomainContext>
<ds:EMSalesDomainContext />
</telerik:RadDomainDataSource.DomainContext>
</telerik:RadDomainDataSource>
7 Answers, 1 is accepted
That is very weird. Could you please open a separate support ticket and attach a sample project the demonstrates this. We will examine it immediately to see what is wrong.
Thanks in advance. We are looking forward to hearing from you.
Regards,
Ross
the Telerik team
Resolved by Telerick support, might help someone else.
You need to define the parameter in XAML and later you can change its Value. This is because the query method:
public EntityQuery<CustomerProductGroup> GetProductGroupsForCustomerQuery(int CustomerId)
... is searched using reflection and we need the parameter in order to locate the exact method.
So you should do this in XAML:
<
telerik:RadDomainDataSource
x:Name
=
"ProductsDataSource2"
AutoLoad="False"
QueryName="GetProductGroupsForCustomerQuery"
>
<telerik:RadDomainDataSource.QueryParameters>
<telerik:QueryParameterParameterName="CustomerId"/>
</telerik:RadDomainDataSource.QueryParameters>
<telerik:RadDomainDataSource.DomainContext>
<ds:EMSalesDomainContext/>
</telerik:RadDomainDataSource.DomainContext>
</
telerik:RadDomainDataSource
>
And then in code-behind you only need to do this:
privatevoid
btnGetDataClicked(
object
sender, RoutedEventArgs e)
{
ProductsDataSource2.QueryParameters.Single(p => p.ParameterName == "CustomerId").Value = 4;
ProductsDataSource2.Load();
}
Don't Clear the parameters.
Richard
Thank you
I've seen this error from time to time but didn't realize it was because of the parameter.
Now I know the answer.
Useful technique I found if you want to reuse a raddomaindatasource but with different queryname/parameters.
Set the queryname to null (preventing it from using reflection to scan the query methods on the domaincontext), add remove parameters etc, then set the queryname to query method you need.
cheers
pb