This is a migrated thread and some comments may be shown as answers.

Not Finding Method With Parameters in DomainContext

7 Answers 187 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
ANDY
Top achievements
Rank 1
ANDY asked on 21 Feb 2011, 11:49 AM

 

 

 

 

 

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

Sort by
0
Rossen Hristov
Telerik team
answered on 21 Feb 2011, 01:40 PM
Hello ANDY,

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
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
ANDY
Top achievements
Rank 1
answered on 24 Feb 2011, 10:05 AM

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:RadDomainDataSourcex: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:

privatevoidbtnGetDataClicked(objectsender, RoutedEventArgs e)

{

    ProductsDataSource2.QueryParameters.Single(p => p.ParameterName == "CustomerId").Value = 4;

    ProductsDataSource2.Load();

}


Don't Clear the parameters.

0
richard
Top achievements
Rank 1
answered on 22 Mar 2011, 01:44 PM
the .Single is not an option when I try that method.

Richard
0
Ondrej
Top achievements
Rank 2
answered on 14 Apr 2011, 10:12 PM
Did you Solve this problem some how?, I have same problem. I have RadDomainDataSource only in CodeBehind

Thank you
0
richard
Top achievements
Rank 1
answered on 15 Apr 2011, 12:21 PM
I decided to use a load operation on a domain context instead of fighting the .Single problem
0
Josef Rogovsky
Top achievements
Rank 2
answered on 14 Jul 2011, 08:31 PM
Thanks,

I've seen this error from time to time but didn't realize it was because of the parameter.

Now I know the answer.
0
P
Top achievements
Rank 1
answered on 31 Jan 2012, 04:54 PM
Hi,

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
Tags
DomainDataSource
Asked by
ANDY
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
ANDY
Top achievements
Rank 1
richard
Top achievements
Rank 1
Ondrej
Top achievements
Rank 2
Josef Rogovsky
Top achievements
Rank 2
P
Top achievements
Rank 1
Share this question
or