QDSCV using query name instead of query

2 posts, 0 answers
  1. Colin Cowie
    Colin Cowie avatar
    10 posts
    Member since:
    May 2010

    Posted 19 Apr 2011 Link to this post

    Is there any way of using the QueryableDomainServiceCollectionView (for an MVVM implementation), and assigning the query using the query name rather than the query itself?  We're trying to implement a generic lookup dialog that will be passed a number of parameters, including the query name, and parameters for the query, and which will then display a grid with the returned data from the query.

    I've already tested out converting our DomainDataSource driven maintenance and enquiry routines to using the QueryableDomainServiceCollectionView, which works fine, but each of those is being assigned a specific query from our context. 

    I believe I could use reflection to find the query I'm interested in, and have already tried this partially, using:


    But I'm not sure where to go from here, to assign the EntityQuery<Vehicle> variable that I require to initiialise the QueryableDomainServiceCollectionView with.

    Any assistance you could give would be great.


  2. Rossen Hristov
    Rossen Hristov avatar
    2477 posts

    Posted 19 Apr 2011 Link to this post

    Hello Colin Cowie,

    You are correct. You have to pass in the actual query and can't simply pass its name as a string. You can find it with reflection -- that's what we do as well. You also need to know the entity type, i.e. Vehicle. 

    Once you have the EntityQuery instance (i.e. the method on the domain context) and the entity type you can create a generic QDSCV with Activator.CreateInstance. Something like this:

    var genericType = typeof(QueryableDomainServiceCollectionView<>)
    .MakeGenericType(new System.Type[] { <<the entity type here>> });

    var view =
    , this.DomainContext
    , this.EntityQuery);

    This is what RadDomainDataSource does internally when it constructs its QDSCV. If you have the source code all of this can be found in the RadDomainDataSource.EntityQuery.cs file for your reference.

    Let me know if there are problems.

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top