Predicate Bucket or Stored Procedure Projection

Posts   
 
    
AndrewH
User
Posts: 19
Joined: 11-Jul-2007
# Posted on: 11-Jul-2007 04:29:32   

Hi

I'm new to LLBLGenPro (and ORM) and so far, I'm pretty happy with it. What I would like to know is what is the best practice to get the following into an EntityCollection? From the docs it seems there are two alternatives. 1) Used a stored procedure and project the result into the desired EntityCollection. 2) Construct a complex predicate bucket and Fetch the result I also played around with using views, but, 1) or 2) seemed like better solutions. Here is the SQL (Oracle) I want to use

        select * 
            from TableA
            where TableA.Field1=<value>
            and TableA.id in
            (
                select 
                    distinct TableB.id
                    from TableB
                    left join TableC on TableC.id = TableB.TableC_Id
            );

In 1) <Value> would be a parameter to the stored proc In 2) the base predicate bucket would be created from a GetRelationInfoTableA() method

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Jul-2007 08:55:40   

I would like to know is what is the best practice to get the following into an EntityCollection? From the docs it seems there are two alternatives. 1) Used a stored procedure and project the result into the desired EntityCollection. 2) Construct a complex predicate bucket and Fetch the result

Both are workable solutions, so choose what suits you best. In general I'd recommend using the second approach in order to keep most of the work in code rather than in the database. This comes handy whenever you need to port the code to a different database type.