Apologies if this is listed elsewhere but I can't see it. I've installed the May preview and the code generation is now failing, it wasn't in the March version. It fails on one of my custom querys saying
Parameter n of query operation nnn is invalid: query parameters cannot be collections. The parameter in question is an
IEnumerable<int> which I think should be valid.
The accompanying doc says it should be valid and it worked in the March version. Am I missing something?
Edit: There's no such problem with a ServiceOperation with same interface.
Query parameters must be URL serializable. Because of this Query operations no longer allow their parameters to be collections. This is something that was changed in the May preview.
Can you give me some more detail as to what you are trying to accomplish? There might be a new way of doing it in the May preview.
.Net RIA ServicesDomainService
Please click the "Mark as answer" link if this answered your question
I'm trying to return a query where the filter includes a collection of records identified by ID. The collection will have been chosen by the user, so there's no way to predict the sequence. The only way I could see this happening is if I called a service
operation and then called the Query.
I understand that you may have technical issuing in the get for the collection parameters, but I would have thought this a common requirement.
This is still an issue for me. Basically I'm passing a IEnumerable<int> which is a collection of keys which I use to constrain the joins internally. I need to return a Query as the results are a collection.
Is there a pattern for this? Either that or please reverse out and reimplement as in March :)
Unfortunately I don't believe it is. The middle tier operation has business logic, not a simple query, to calculate the results. I'm creating a collection of entities to return as IQueryable<Entity>. Using load means I'm filtering the same type of objects
I want to return doesn't it? I want to pass in a query/collection of items that don't relate to the set being returned. Can I override the load method on the server side?
I'm not sure if this is the metaphor for the correct usage of RIA Services, but ultimately I would expect the business logic to be moved up to the middle tier and not reside in the presentation layer at the client.
In summary I passing a collection of object ids that are used to filter the entities considered for the creation of the returned set, this is what my signature should look like:
[Query]
IQueryable<EntityB> GetNextEntityBThatMatchesBusinessLogic(IEnumerable<EntityA> filterCollection, DateTime start, DateTime end, int EntiyC, int EntityD)
As you can see the returned items are derived from both business logic and associations to other entities. I don't believe the load can return different typs or accept different parameters.
I have same problem, except now in July 2009 Preview. I have to pass my string[] parameter as joined string and then on the callee site split it. So i would appreciate less cumbersome approach...
I have same problem, except now in July 2009 Preview. I have to pass my string[] parameter as joined string and then on the callee site split it. So i would appreciate less cumbersome approach...
You can try using an XElement instead of the joined string, that is a little less cumbersome
It is hard to track if a question has been answered or not if you deep dive old posts like this, if you want to refer to an old post please put a link to it in your own question. There are filters available for these forums that only display unanswered posts
which makes it easy to miss questions added to old posts.
Nedster657
Member
48 Points
63 Posts
May preview problem - Query parameters cannot be collections
May 15, 2009 04:05 PM | LINK
Apologies if this is listed elsewhere but I can't see it. I've installed the May preview and the code generation is now failing, it wasn't in the March version. It fails on one of my custom querys saying Parameter n of query operation nnn is invalid: query parameters cannot be collections. The parameter in question is an IEnumerable<int> which I think should be valid.
The accompanying doc says it should be valid and it worked in the March version. Am I missing something?
Edit: There's no such problem with a ServiceOperation with same interface.
Joseph_C
Member
138 Points
29 Posts
Re: May preview problem - Query parameters cannot be collections
May 15, 2009 05:39 PM | LINK
Query parameters must be URL serializable. Because of this Query operations no longer allow their parameters to be collections. This is something that was changed in the May preview.
Can you give me some more detail as to what you are trying to accomplish? There might be a new way of doing it in the May preview.
.Net RIA Services DomainService
Joseph Connolly
Nedster657
Member
48 Points
63 Posts
Re: May preview problem - Query parameters cannot be collections
May 18, 2009 09:26 AM | LINK
I'm trying to return a query where the filter includes a collection of records identified by ID. The collection will have been chosen by the user, so there's no way to predict the sequence. The only way I could see this happening is if I called a service operation and then called the Query.
I understand that you may have technical issuing in the get for the collection parameters, but I would have thought this a common requirement.
What's the suggested approach?
Thanks.
Nedster657
Member
48 Points
63 Posts
Re: May preview problem - Query parameters cannot be collections
May 20, 2009 08:35 AM | LINK
<shameless bump>
This is still an issue for me. Basically I'm passing a IEnumerable<int> which is a collection of keys which I use to constrain the joins internally. I need to return a Query as the results are a collection.
Is there a pattern for this? Either that or please reverse out and reimplement as in March :)
Joseph_C
Member
138 Points
29 Posts
Re: May preview problem - Query parameters cannot be collections
May 20, 2009 08:36 PM | LINK
Is it possible for you to do the filtering using the Load method overrides? Both these examples I use AdventureWorks Employee table.
EmployeeDomainContext _dc = new EmployeeDomainContext();public MainPage(){
InitializeComponent();
this.dataGrid1.ItemsSource = _dc.Employees;IQueryable<Employee> query = new Employee[0].AsQueryable();query = query.Where(e => e.EmployeeID < 5);
_dc.LoadEmployees(query,
null); // This will pass the query filter to the server where it will be executed there}
You can also use the DomainDataSounce to filter based on user selections:
<!-- MainPage.xaml -->
<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Ria.Controls" x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:riaData="clr-namespace:System.Windows.Data;assembly=System.Windows.Ria.Controls" xmlns:ds="clr-namespace:SilverlightApplication1.Web" > <Grid x:Name="LayoutRoot" Background="White"> <riaControls:DomainDataSource x:Name="DDS" LoadSize="30" LoadMethodName="LoadEmployees" AutoLoad="True" >
<riaControls:DomainDataSource.FilterDescriptors> <riaData:FilterDescriptorCollection /> </riaControls:DomainDataSource.FilterDescriptors>
<riaControls:DomainDataSource.DomainContext> <ds:EmployeeDomainContext></ds:EmployeeDomainContext> </riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<StackPanel> <data:DataGrid x:Name="dataGrid1" ItemsSource="{Binding Data, ElementName=DDS}" Height="Auto" MinHeight="100" MaxHeight="600" IsReadOnly="True" /> <Button x:Name="filterButton" Click="filterButton_Click" Content="Filter"></Button> <Button x:Name="undoButton" Click="undoButton_Click" Content="Undo Filter"></Button> </StackPanel>
</Grid></
UserControl>//MainPage.xaml.cs
private void filterButton_Click(object sender, RoutedEventArgs e){
FilterDescriptor aFilter = new FilterDescriptor("EmployeeID", FilterOperator.IsEqualTo, 1);DDS.FilterDescriptors.Add(aFilter);
}
private void undoButton_Click(object sender, RoutedEventArgs e){
DDS.FilterDescriptors.Clear();
}
Joseph Connolly
Nedster657
Member
48 Points
63 Posts
Re: May preview problem - Query parameters cannot be collections
May 21, 2009 10:25 AM | LINK
Unfortunately I don't believe it is. The middle tier operation has business logic, not a simple query, to calculate the results. I'm creating a collection of entities to return as IQueryable<Entity>. Using load means I'm filtering the same type of objects I want to return doesn't it? I want to pass in a query/collection of items that don't relate to the set being returned. Can I override the load method on the server side?
I'm not sure if this is the metaphor for the correct usage of RIA Services, but ultimately I would expect the business logic to be moved up to the middle tier and not reside in the presentation layer at the client.
In summary I passing a collection of object ids that are used to filter the entities considered for the creation of the returned set, this is what my signature should look like:
[Query]
IQueryable<EntityB> GetNextEntityBThatMatchesBusinessLogic(IEnumerable<EntityA> filterCollection, DateTime start, DateTime end, int EntiyC, int EntityD)
As you can see the returned items are derived from both business logic and associations to other entities. I don't believe the load can return different typs or accept different parameters.
tomas.k
Member
47 Points
46 Posts
Re: Re: May preview problem - Query parameters cannot be collections
Aug 13, 2009 10:17 AM | LINK
Hi,
I have same problem, except now in July 2009 Preview. I have to pass my string[] parameter as joined string and then on the callee site split it. So i would appreciate less cumbersome approach...
ColinBlair
All-Star
28591 Points
4834 Posts
Re: Re: May preview problem - Query parameters cannot be collections
Aug 13, 2009 03:52 PM | LINK
You can try using an XElement instead of the joined string, that is a little less cumbersome
It is hard to track if a question has been answered or not if you deep dive old posts like this, if you want to refer to an old post please put a link to it in your own question. There are filters available for these forums that only display unanswered posts which makes it easy to miss questions added to old posts.
http://www.RiaServicesBlog.net
ColinBlair on Twitter
MVVM and RIA Services
eecsaky
Member
282 Points
47 Posts
Re: May preview problem - Query parameters cannot be collections
Sep 01, 2009 12:31 AM | LINK
To send collection parameters I use the Json Serialization. In my Open Source Project, SilverBox, I've two extension methods to do it.
http://silverbox.codeplex.com
You must to get the latest verion from the source control (27232 commit or higher)
Download Latest!
:-)
Blog: http://geeks.ms/blogs/eecsaky
Phone: +34 663 139 974
Tour_n
Member
41 Points
31 Posts
Re: May preview problem - Query parameters cannot be collections
Sep 01, 2009 04:58 AM | LINK
I have that problem to ,
if you use IEnumerable<int> or the basic object
my workaround will be change into string by concat that list and spilt it out in server again