Typed Views and entities

Posts   
 
    
Posts: 497
Joined: 08-Apr-2004
# Posted on: 20-Jan-2005 17:56:34   

Hi Frans,

I know that entities based on DB views is something you're working on for the next release, but I wanted to check something with you before i go too far down an implementation route:

I have a view that is basically a de-normalised view of users and thier relationship with various things, e.g.:

UserID * Record_Type * Record_ID 1 * POLICY * 1 1 * POLICY * 45 1 * LEGISLATION * 3

Now, what I want to is write code such as:

"List all policy records associated with userID 1"

Can I do this with predicates? I suspect the answer is "not currently"?

I also suspect that the solution for the time being is to fire 2 queries off to the DB: 1: "List all Record_IDs from the view where RecordType = POLICY and UserID = 1" 2: "List all policy records where ID's are in the comma-seperated list of record_IDs fetched in query #1."

My reservations about this solution is that its 2 database hits (not too big a deal though), and more importantly, that there is a limit on how many comma-seperated "things" you can filter on (think its a thousand). So this shortened SQL would fail:

Select  * from policy where ID in (1,2,3...1001)

Thanks for your thoughts!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Jan-2005 18:46:19   

You can't join with a view yet indeed, so if you want to use the view as a source for filtering, you can't. However the view is also a result of a query, so you could try to use parts of that query in your filter to get the results you want, thus not based on the view but on table data.

Frans Bouma | Lead developer LLBLGen Pro