SubSonic Forums
All Your Database Are Belong To Us

DB.SelectAllColumnsFrom [BUG]

Latest post 05-19-2008 7:45 PM by robsworld. 3 replies.
  • 05-19-2008 2:43 AM

    DB.SelectAllColumnsFrom [BUG]

    Hi there,

    I recently came across a bug when using DB.SelectAllColumnsFrom()

    With the following query: 

     string r = DB.SelectAllColumnsFrom<Competition>()
                    .From(Competition.Schema)
                    .InnerJoin(UserCompetition.Schema)
                    .Where(UserCompetition.Columns.UserCompetitionID).IsEqualTo(userCompetitionID)
                    .BuildSqlStatement();

     

    It produces: (notice how it is selecting 2x times)

    SELECT [dbo].[Competition].[CompetitionID], [dbo].[Competition].[Name], [dbo].[Competition].[IsDeleted], [dbo].[Competition].[OpeningTotal]                  [dbo].[Competition].[CompetitionID], [dbo].[Competition].[Name], [dbo].[Competition].[IsDeleted], [dbo].[Competition].[OpeningTotal]FROM [dbo].[Competition],[dbo].[Competition]
    INNER JOIN [dbo].[UserCompetition] ON [dbo].[Competition].[CompetitionID] = [dbo].[UserCompetition].[CompetitionID]
    WHERE UserCompetitionID = @UserCompetitionID

    Thanks in advance 

    Regards DotnetShadow 

     

    Filed under: , , ,
  • 05-19-2008 10:15 AM In reply to

    Re: DB.SelectAllColumnsFrom [BUG]

    Why are you calling From two times?

    You can try
    DB.Select().From(Competition.Schema)

    If I am I because I am I, and You are You because You are You, then I am I, and you are you. But If I am I because You are You, and You are You because I am I, then I am not I and You are not You. -Rabbi of Kotzk

  • 05-19-2008 3:22 PM In reply to

    Re: DB.SelectAllColumnsFrom [BUG]

    Calling FROM twice here is the the problem. I had thought about stripping duplicates in the FROM collection, but then that would cause all kinds of problems - especially running a join on a table to itself :).


    Interesting issue though - wondering best way to get around it...

     

    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us!

  • 05-19-2008 7:45 PM In reply to

    Re: DB.SelectAllColumnsFrom [BUG]

    Sorry guys my bad I didn't realise the SelectAllColumnsFrom had the FROM part I assumed it was just selecting the columns from a particular table not using it as part of the join

    Regards Dotnetshadow

Page 1 of 1 (4 items) | RSS