Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 18, 2012 05:44 AM by Decker Dong - MSFT
Dec 17, 2012 05:50 PM|LINK
I'm trying to display a project with a 0-many relationships for suspects and victims.
Approach 1: Having to go back to database to fetch suspects, and then victims on ItemDataBound event of a listview seems costly.
from dbo.Project pj
left outer join (dbo.Victim v inner join dbo.person pv on v.personid = pv.personid) on t.ProjectNo = v.ProjectNo
left outer join (dbo.Suspect s inner join dbo.person ps on s.personid = ps.personid) on t.ProjectNo = s.ProjectNo
But the all suspects are listed on every victim instead of the project, which makes the count wrong. Also, it will have an error on paging(page size) and when I click prev/next on the result set on the client end.
If anybody has a more effiecient way of doing this - [ DataLoadOptions(?), XML sql returns(?) ], please let me know.
Dec 17, 2012 06:55 PM|LINK
For smaller resultsets, it's fine to make a round trip to the server. SQL Server can handle it just fine.
No need to overthink this one.
Also, there's no such thing as 0-to-many. :)
Dec 18, 2012 05:44 AM|LINK
What's that? Do you mean there's no foreignkey existing for an existing record in the primary (1) table?