Print Page | Close Window

Cannot get result of a Parametrized named query using Fakestore mode

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3918
Printed Date: 25-Oct-2025 at 12:46pm


Topic: Cannot get result of a Parametrized named query using Fakestore mode
Posted By: kdev
Subject: Cannot get result of a Parametrized named query using Fakestore mode
Date Posted: 22-Jan-2013 at 1:43am
Hi,

I’m trying to make a parametrized named query request and then get its corresponding results.
The request is the following

              // on the client in a repository class 
        public Task<IEnumerable<Company>> GetCompaniesStartingWithPrefix(string prefix)
        {
            return Manager.GetCompaniesStartingWithPrefix(prefix).ExecuteAsync();
        }

              // exists in the entity manager class
        public EntityQuery<company> GetCompaniesStartingWithPrefix(string prefix)
        {
            var query = new EntityQuery<Company>("CompaniesStartingWithPrefix", this);
            query.AddParameter(new EntityQueryParameter(prefix));
            return query;
        }

In which I try to get a set of “Company” records which satisfy a certain condition.
In the server side , I wrote the following code:

    [EnableClientAccess]
    public class CompaniesNamedQueryProvider
    {
        public IQueryable<Company> GetCompaniesStartingWithPrefix(string prefix)
        {
            return new EntityQuery<Company>().Where(item => item.Name.StartsWith(prefix));
        }
    }

The problem was that – in fakestore mode - I encountered the following problem:
EntityServerException: named queries must have a FetchStrategy of either DataSourceOnly or Optimized.

Even if change the value of the QueryStrategy property of the EntityQuery instance used for the request to “DataSourceOnly” value, there is no effect.

The same scenario in “Debug” mode works fine.

Did I missed something ??

Note :
DevForce version : 7.0.3.0
cocktail 2.2




Replies:
Posted By: kimj
Date Posted: 22-Jan-2013 at 1:19pm
Using "specialized" named queries when faking is not currently supported.  These queries must be executed with the DataSourceOnly strategy by definition, and faking, by definition, uses a disconnected EntityManager to mimic the data store.
 
How important is this feature for you?


Posted By: kdev
Date Posted: 22-Jan-2013 at 1:30pm
I want to share some logic between the client and the server.

Actually all my queries are define on the client (Silverlight) and some might be very complex.
This fits my needs when I only need to show the result on the screen, but often I need to print this result.
For the reporting parts, I use Telerik Reporting. All the reports are generated on the server.

I don't want to duplicate and maintain the code for those queries on both side, that's why I wanted to use the "specialized" queries which seemed to fits my needs.

Now I use a lot the FakeStore as it is in Temphire. If I can't use the "specilaized" queries in the Fake mode then that's an issue for me.

Any other way to share query logic between client and server with devforce ?



Posted By: kdev
Date Posted: 25-Jan-2013 at 12:12am
Any though about how to share this logic between the client and the server without duplicate the code ?


Posted By: kimj
Date Posted: 25-Jan-2013 at 8:15am
Sorry I hadn't gotten back to you. Named queries are the best approach for your needs. I've been trying to get in touch with the original engineer to see why the restriction with faking exists.


Posted By: kimj
Date Posted: 15-Feb-2013 at 10:07am
kdev - We've fixed this problem in the upcoming 7.1.0 release.


Posted By: kdev
Date Posted: 26-Feb-2013 at 7:54pm
thank you



Print Page | Close Window