Many to Many Issue

Posts   
 
    
scottsimms
User
Posts: 12
Joined: 13-Feb-2007
# Posted on: 20-Feb-2007 06:25:48   

Hi,

First of all, we are using SQL Server 2005 Express with Adapter method.

I am trying to traverse a many-to-many relationship and I'm getting an exception: 'The multi-part identifier "CountWA.dbo.USER_ROLE_TB.USER_ID" could not be bound...'.

This appears to be caused by missing alias names in the select list - here is the generated SQL:

Query: SELECT DISTINCT [CountWA].[dbo].[USER_ROLE_TB].[USER_ROLE_ID] AS [UserRoleId], [CountWA].[dbo].[USER_ROLE_TB].[USER_ID] AS [UserId], [CountWA].[dbo].[USER_ROLE_TB].[ROLE_ID] AS [RoleId] FROM (( [CountWA].[dbo].[USER_TB] [LPA__1] INNER JOIN [CountWA].[dbo].[USER_ROLE_TB] [LPA_U2] ON [LPA__1].[USER_ID]=[LPA_U2].[USER_ID]) INNER JOIN [CountWA].[dbo].[ROLE_TB] ON [CountWA].[dbo].[ROLE_TB].[ROLE_ID]=[LPA_U2].[ROLE_ID]) WHERE ( ( [LPA__1].[USER_ID] = @UserId1))

Parameter: @UserId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 46.

Any ideas appreciated.

Thanks,

Scott.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 20-Feb-2007 06:32:59   

Please post the corresonding code, and the runtimeLibrary version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7718)

scottsimms
User
Posts: 12
Joined: 13-Feb-2007
# Posted on: 20-Feb-2007 06:41:37   

Hi,

Runtime version is : 2.0.0.0.

Our code is:

Function FetchRoles(aUser as UserEntity) as EntityCollection(Of UserRoleEntity)

Dim entityCollection As New EntityCollection(Of UserRoleEntity)()

Adapter.FetchEntityCollection(entityCollection,aUser.GetRelationInfoRoleCollectionViaUserRole())

Return entityCollection

End Function

Thanks,

Scott.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 20-Feb-2007 08:59:31   

You are using the wrong relation.

You are fetching a UserRole collection and you are using the relation between User and Role "GetRelationInfoRoleCollectionViaUserRole"

scottsimms
User
Posts: 12
Joined: 13-Feb-2007
# Posted on: 21-Feb-2007 04:51:40   

Thanks a lot, that works fine.