Group By with Aggregate Function Usage

Posts   
 
    
GeoffreyD
User
Posts: 2
Joined: 04-Oct-2007
# Posted on: 04-Oct-2007 15:54:29   

Hi

I'm still pretty new to LLBLGen and am trying to understand how to programmatically replace the following select statement with the generated code (I'm fine with regular selects - it is the grouping and aggregation function I'm having trouble with):

select gf.[FileName], gf.[File], gf.[FileVersion] from tb_GameFile gf inner join (select [FileName], max(FileVersion) as [Version] from tb_GameFile group by [FileName]) it on it.[FileName] = gf.[FileName] and it.[Version] = gf.[FileVersion]

Basically I start out with a list of files that I want to retrieve from the DB (of which there will be duplicates in the DB at different versions). I'm just trying to get the latest version of each file into a collection.

Could someone give me some sample code for performing this?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Oct-2007 16:10:23   
GeoffreyD
User
Posts: 2
Joined: 04-Oct-2007
# Posted on: 04-Oct-2007 16:39:22   

Sorry, I forgot to mention that I'm looking to implement in c#. I'm not at all familiar with VB.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Oct-2007 11:36:21   

I'm not at all familiar with VB.

The concept is the same, so all you need is to grab the concept, the rest is just minor syntax differences. Other than not using semi colons, the only substantial difference you might see is the way variables are declared. eg. VB code: Dim scalarNestedSubQueryRelation As IRelationCollection = New RelationCollection

C# code: IRelationCollection scalarNestedSubQueryRelation = New RelationCollection();