Sub Selects

Posts   
 
    
siegemos
User
Posts: 47
Joined: 25-Jun-2007
# Posted on: 28-Apr-2008 18:40:15   

Hi all,

I'm struggling converting the following Sql into and LLBLGen TypedListDAO query



SELECT DISTINCT [SeniorCMS_Master].[dbo].[aspnet_Roles].[RoleId], 
                [SeniorCMS_Master].[dbo].[aspnet_Roles].[RoleName], 
                (
                    SELECT COUNT([SeniorCMS_Master].[dbo].[SN_CMS_PageAccessUserRoles].RoleId) 
                    FROM [SeniorCMS_Master].[dbo].[SN_CMS_PageAccessUserRoles]
                    WHERE 
                        [SeniorCMS_Master].[dbo].[SN_CMS_PageAccessUserRoles].RoleId = [SeniorCMS_Master].[dbo].[aspnet_Roles].[RoleId] AND
                        [SeniorCMS_Master].[dbo].[SN_CMS_PageAccessUserRoles].PageId = 276
                ) AS PageCounter
FROM 
[SeniorCMS_Master].[dbo].[aspnet_Roles]


Is there a way to sub-selects like this? I've been going round in circles for a long time now.

Thanks,

Chris.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 28-Apr-2008 20:49:22   

You can accomplish this with a ScalarQueyExpression, see the following thread:

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11244