SubSonic Forums
All Your Database Are Belong To Us

Select all the columns with Inner Join

Latest post 10-06-2008 11:52 AM by oraculum. 2 replies.
  • 10-05-2008 7:37 PM

    Select all the columns with Inner Join

    How can I make this selection:

    SELECT User .*,  Filial.Nome

    FROM User

    INNER JOIN Filial

    ON User.FilialID = Filial.ID

    WHERE Usuario.ID = 1

    Filed under: ,
  • 10-06-2008 11:09 AM In reply to

    Re: Select all the columns with Inner Join

    Take a look at the sample queries for the 2.1 version at http://blog.wekeroad.com/2008/01/10/subsonic-version-21-pakala-preview-the-new-query-tool/

    So it would be something like:

    List<User> result = new
    Select("User.*", "Filial.None")
    .From(User).InnerJoin(User.FilialID, Filial.ID)
    .ExecuteTypedList<User>();
  • 10-06-2008 11:52 AM In reply to

    Re: Select all the columns with Inner Join

    Kbradl1 Thanks!


    For very little I did not hit, I had tried before to do the following:

     

      SubSonic.SqlQuery q = new Select("Usuario.*", Subdb.Filial.NomeColumn)
                .From(Subdb.Usuario.Schema)
                .InnerJoin(Subdb.Filial.IdColumn, Subdb.Usuario.FilialLogColumn)
                .Where(Subdb.Usuario.IdColumn).IsEqualTo(id);

     

    Thus he returned the following error:

     

    Error    2    The best overloaded method match for 'SubSonic.Select.Select(params string[])' has some invalid arguments    c:\inetpub\wwwroot\sanian\App_Code\Usuario.cs    297    31    http://localhost/sanian/

    AND

    Error    3    Argument '2': cannot convert from 'SubSonic.TableSchema.TableColumn' to 'string'    c:\inetpub\wwwroot\sanian\App_Code\Usuario.cs    297    55    http://localhost/sanian/

     

    So the problem was here: Subdb.Filial.NomeColumn  what should be placed in this way: "Filial.Nome"

     

     

Page 1 of 1 (3 items) | RSS