How can do this Query in LLBL- Self Servicing

Posts   
 
    
DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 20-Mar-2007 17:05:15   

This is my SQL Query


SELECT   Costs.costkey, Costs.owner, Costs.costcategory, Costs.costamount, Costs.costdesc, Costs.costdate, costypes.costcategory AS CAT, 
                      [user].username
FROM         Costs INNER JOIN
                      costypes ON Costs.costcategory = costypes.costtypekey INNER JOIN
                      [user] ON Costs.owner = [user].userkey

What i would like to be able to do Is execute this query in LLb I have looked but i am not getting it, sorry guy its probley obvious.confused

I am using a collection in a winforms situation so my inital code for binding is:


        Dim CostFilter As PredicateExpression = New PredicateExpression()
        CostFilter.Add(CostsFields.Costcategory = Me.RadComboBox1.SelectedValue)
        Me.CostsCollection1.GetMulti(CostFilter)

But i need the username value not just the user key thats in the collection, if you can see what I mean.

Thanks

Jason

Aurelien avatar
Aurelien
Support Team
Posts: 162
Joined: 28-Jun-2006
# Posted on: 20-Mar-2007 17:27:43   

Hi,

prefetchpaths are designed to do that, see the section Generated code - Prefetch Paths in the doc.

You need to create a prefechpath starting with Costs to user and add it to the SaveMulti method.

after that, you will access to the user with Me.CostsCollection1.User

Cheers,

Aurélien

DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 20-Mar-2007 18:33:48   

Aurelien wrote:

Hi,

prefetchpaths are designed to do that, see the section Generated code - Prefetch Paths in the doc.

You need to create a prefechpath starting with Costs to user and add it to the SaveMulti method.

after that, you will access to the user with Me.CostsCollection1.User

Cheers,

Aurélien

Hi I am now using this code, but it is still not working. Any more help would be great please


        Dim prefetchPath As IPrefetchPath = New PrefetchPath(CType(EntityType.CostsEntity, Integer))
        prefetchPath.Add(CostsEntity.PrefetchPathUsername)
        Dim CostFilter As PredicateExpression = New PredicateExpression()
        CostFilter.Add(CostsFields.Costcategory = Me.RadComboBox1.SelectedValue)
        Me.CostsCollection1.GetMulti(CostFilter, prefetchPath)

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 21-Mar-2007 02:20:29   

You can use a dynamic list if you want the exact query that you posted at the top. The prefetch path will make it so that all Costs entities that are fetch have their User property populated so you could do something like this after the GetMulti(); CostsCollection1[0]User.Username to access the username.

If you want one resultset like this then you will need to use dynamic lists. If you always need Costs to return the User data then you may look into Fields on Related Fields in the manual.

DelG
User
Posts: 18
Joined: 11-Jan-2007
# Posted on: 21-Mar-2007 02:38:32   

bclubb wrote:

You can use a dynamic list if you want the exact query that you posted at the top. The prefetch path will make it so that all Costs entities that are fetch have their User property populated so you could do something like this after the GetMulti(); CostsCollection1[0]User.Username to access the username.

If you want one resultset like this then you will need to use dynamic lists. If you always need Costs to return the User data then you may look into Fields on Related Fields in the manual.

Thanks very much for you help, in the end I solved it by mapping the fields in the LLb IDE to the costs Entity. Now I have them as one resultset, and can work with them in a grid etc.

I still have to prefetchpath them or I get an error, something about the collection has been modified confused but it works, & i am a happy little developer.

Using LLB & Janus WinForms Gridex is awesome, i have never seen a Grid control like thissmile , its so powerful... and with LLBL its just....stuck_out_tongue_winking_eye

Jason