SubSonic Forums
All Your Database Are Belong To Us

"Object must implement IConvertible" error

Latest post 10-22-2008 12:11 AM by ranomore. 1 replies.
  • 10-17-2008 1:26 AM

    "Object must implement IConvertible" error

    I'm using version 2.1 right now and am running into an issue.  I have two tables: Users and Items.  The Users table has a primary key of UserID, along with another column called UserName.  The Items table has a foreign key relation to the Users table using the UserName column instead of the UserID column.

    Inside the SubSonic-generated User class, I see the following code for accessing the Items collection:

    public ItemCollection Items()

    {

    return new ItemCollection().Where(Item.Columns.UserName, UserID).Load();

    }

    This generates an "Object must implement IConvertible" error, which makes sense because it's trying to compare the UserID (which is an int column) to the UserName (which is a string column).  Is my database set up incorrectly or is there a way to configure SubSonic to recognize that the foreign key isn't using the parent's primary key?

     

  • 10-22-2008 12:11 AM In reply to

    • ranomore
    • Top 10 Contributor
    • Joined on 11-05-2007
    • Salt Lake City
    • Posts 322

    Re: "Object must implement IConvertible" error

    everything is partial classes, so you should be able to add / override the generated methods in your own class.

Page 1 of 1 (2 items) | RSS