SubSonic Forums
All Your Database Are Belong To Us

How do you use DB.Insert() with multiple values and qualified column names?

Latest post 08-03-2008 5:18 PM by Dawnthorn. 3 replies.
  • 07-22-2008 10:41 PM

    How do you use DB.Insert() with multiple values and qualified column names?

    Hi there,

    I'm trying to use the DB.Insert()  as follows:

    SubSonic.Insert i = DB.Insert().Into(MyTable.Schema)
                    .Values("abc", "xyz");

    but it complains that I don't have the right number of columns for select list

    I checked DB.Insert().Into(MyTable.Schema).SelectColumns and I noticed that the primary key is not included so how would u fill this in?

    I tried the following:
    SubSonic.Insert i = new Insert(MyTable.Schema);
    i.Value(MyTable.NameColumn, "abc");
    i.Value(MyTable.CompanyColumn, "xyz");

    this seems to work but the problem is the names of the columns are not fully qualified so what can be done

    Regards DotnetShadow

     

     

  • 07-23-2008 5:46 AM In reply to

    Re: How do you use DB.Insert() with multiple values and qualified column names?

     

    I use this method:

    MyTable i = new MyTable();
    i.NameColumn = "abc";
    i.CompanyColumn = "xyz";
    DB.Save(i);

    What do you mean by

    robsworld2006:

    ... the names of the columns are not fully qualified ...

     Are you talking about the SQL that hits the database ?

     

  • 07-23-2008 10:09 PM In reply to

    Re: How do you use DB.Insert() with multiple values and qualified column names?

    Thanks for replying,

    I should of made myself more clearer I want to use the DB.Insert() so that I can get the BuildSQLStatement() when doing so there column names are not fully qualified. The reason I need BuildSQLStatement() is so that I can do batch inserts | updates

    Regards DotnetShadow

     

     

  • 08-03-2008 5:18 PM In reply to

    Re: How do you use DB.Insert() with multiple values and qualified column names?

    How about this:

    SubSonic.Insert i = DB.Insert().Into(MyTable.Schema, "column1", "column2").Values("abc", "xyz");

     

Page 1 of 1 (4 items) | RSS