Restrict columns returned from a view?

Posts   
 
    
DaveR
User
Posts: 43
Joined: 15-Jun-2004
# Posted on: 08-Sep-2006 01:57:44   

I apologize if this has been asked and answered before.

We have a TypedView that contains many columns. We wish to use any of these columns in the search filter, but return only a distinct subset of the columns to the application.

For example, if the view V contains columns A,B,C,D,E then we may want to execute a query such as

SELECT DISTINCT A,B,C FROM V WHERE D=1 AND E=2

Is this possible in LLBLGen version 1? If not, is it possible in version 2?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 08-Sep-2006 03:08:56   

You can map the view as an entity and then a typed list or dynamic list retrieve a portion of the view like you need.

DaveR
User
Posts: 43
Joined: 15-Jun-2004
# Posted on: 08-Sep-2006 15:29:43   

But with a typed or dynamic list, aren't the filter parameters restricted to the fields of the list, and not the entire view (i.e. fields of the view that are not included in the typed list cannot be searched)?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Sep-2006 15:36:01   

Using a dynamicList, you can select the fields you want to be returned, and use the fields you need as a filter. (no need for the filter to using fields from the returned set of fields).

So map the view to an entity and then use a dynamicList to select fields from this entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Sep-2006 16:52:15   

DaveR wrote:

But with a typed or dynamic list, aren't the filter parameters restricted to the fields of the list, and not the entire view (i.e. fields of the view that are not included in the typed list cannot be searched)?

No, you can create a filter based on all the fields in the entities in the filter and the one you select from. this also counts for views. The dynamic list / typed list controls the fields in the select list (i.e. the SELECT ... statement), the filter/relationcollection controls the entities you select from (FROM ... WHERE... statement).

With a typed view, you could create a dynamic list, as a TypedView has fields generated into the generated code, though if you want to create a typedlist, or want to join with other entities, it's recommended that you map an entity onto the view as Walaa says.

Frans Bouma | Lead developer LLBLGen Pro
DaveR
User
Posts: 43
Joined: 15-Jun-2004
# Posted on: 08-Sep-2006 17:14:32   

Thanks. We have the view mapped to both a TypedView and an Entity, so we should be able to simply create a TypedList with a subset of that entity's fields.

I probably should have realized this ...