Print Page | Close Window

POCO Queries...

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1339
Printed Date: 22-Sep-2025 at 7:49am


Topic: POCO Queries...
Posted By: jsobell
Subject: POCO Queries...
Date Posted: 22-Jun-2009 at 12:05am
It appears that the POCO implementation is a great way of allowing inclusion of short lists of items such as US states in queries, but there are often times when we need to return a subset of a large server side collection and we can't quite see how this would be done.
For example, we would like to return a collection of images where the filename begins with "A", so how would this be implemented?
The standard GetImageCollection() approach appears to have to read every single image into an IEnumerable collection so that the client can subsequently filter them, while the ideal would be to allow GetImageCollection(string myfilter) so the query can be "from img in ImageCollection("A*.*") select img".
I know it's not an ivory tower solution, but is there another way to approach this other than adding a custom webservice?
If we are forced to add the webservice, how can we leverage the existing security session?  When fetching data from SQL server it is passed the query, but the POCO example seems to assume that you return everything and filter afterwards.

Cheers,
 Jason



Replies:
Posted By: kimj
Date Posted: 22-Jun-2009 at 8:12am
We will be adding support for query parameters in the next release, so you'll be able to do GetImageCollection(args..) then.  For now, one workaround would be to use the InvokeServerMethod, which does allow you to pass arguments.


Posted By: ouelletf
Date Posted: 22-Jun-2009 at 8:24am
Would it be possible to also receive the query expression ?

I think you want to respect RIA standard.
Maybe you could have both RIA method, and a custom interface that allow us to receive the expression ?

Your POCO is a really nice feature.


Posted By: kimj
Date Posted: 22-Jun-2009 at 6:27pm
I want to clarify how query expressions and filtering work with POCO queries, since I may have given the impression that filtering of any sort can only be done on the client right now, which is not true.
 
The Where clause or Filter added to a query client-side,  although not passed into the query method, is still executed on the server prior to sending the results to the client.  You can also implement a server-side IEntityServerFetching to add a Filter to POCO queries.   It's true that the query method, as the "data source", may need to load more data than necessary to fulfill the query (and why we will add support for parameters) but not all that data is necessarily returned to the client. 
 


Posted By: jsobell
Date Posted: 22-Jun-2009 at 6:55pm
Thanks Kim,
Yes, I guessed that the sets were filtered at the server end, but the idea of loading 20MB of images into a collection simply to let the server then check the filename is a huge overhead.
We are currently struggling with the undocumented InvokeServerMethodAsync method (did I also mention that there are no examples and it's undocumented? :) )

Cheers,
 Jason


Posted By: kimj
Date Posted: 22-Jun-2009 at 7:06pm
We were just talking about the undocumented InvokeServerMethodAsync at an engineering meeting this morning. :)  It may still remain largely undocumented for another release.  We'll see.
 
There's a snippet in the Help reference (which has the unfortunate name of IdeaBladeDevForceV4ReferenceHelp.chm) for the synchronous version of InvokeServerMethod.  The async signature isn't too different.  If you have any questions, let me know.



Print Page | Close Window