Best practice with joins/views

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 01-Aug-2007 18:05:28   

Hi

I was hoping for a bit of advice on best practice, I'll illustrate it by example in the hope that somebody could post a code-based example in return confused

I'm really new to LLBL... I've got my database set up nicely, and I've manged to bring back a couple of basic data readers with thanks to you guys on here... but now I need to move on a step!

I would like for example to get some information on a product in my database, for example:

SELECT Product.ProductID, Product.Name, Manufacturer.Name, Supplier.Name

So we're getting the product id, name and also the names of the manufacturer and supplier. Usually I would put this in a view in SQL as I've started to write here.

How would I do this with LLBL?

Also, what if I wanted to take this a step further with aggregate queries, and say add a column on the end with the number of times this product has been ordered?

Again, do I create a view then add entities from that view, or is there a better way?

Many (many) thanks

Darren

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Aug-2007 03:50:21   

Hi Darren,

daz_oldham wrote:

I would like for example to get some information on a product in my database, for example:

SELECT Product.ProductID, Product.Name, Manufacturer.Name, Supplier.Name

So we're getting the product id, name and also the names of the manufacturer and supplier. Usually I would put this in a view in SQL as I've started to write here.

How would I do this with LLBL?

You can use PrefetchPaths. Please read LLBLGenPro Help - Using generated code - Adapter - Prefetch paths as there are many helpful examples.

daz_oldham wrote:

Also, what if I wanted to take this a step further with aggregate queries, and say add a column on the end with the number of times this product has been ordered?

Again, do I create a view then add entities from that view, or is there a better way?

You may use DB-Views and retrieve these via LLBLGen. But if you want control the logic of your aggregates and exploit LLBLGen framework, you should use Dynamic List. For a better understanding of the difference between Views, TypedLists and DynamicList please read LLBLGenPro Help - Using generated code - Adapter - Using TypedViews, TypedLists and DynamicLists

If you have more questions about this topic please feel free to reopen this thread wink

David Elizondo | LLBLGen Support Team
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 02-Aug-2007 10:22:32   

Thanks very much - I am some way off getting to needing the aggregate functions - but I will bookmark this for that very day smile

Best regards

Darren