SubSonic Forums
All Your Database Are Belong To Us

Help with Repository Patterm SQL update.

Latest post 05-25-2008 11:22 PM by DanKline. 4 replies.
  • 05-23-2008 11:16 AM

    • DanKline
    • Top 50 Contributor
    • Joined on 12-13-2006
    • West Bend, WI
    • Posts 46

    Help with Repository Patterm SQL update.

     I'm working with Pakala 2.1.3 and have hit an error.  When using the DB.Save(RepObj) function an exception is thrown (Incorrect syntax near the keyword 'WHERE'.).  Drilling into the exception, I found this information which may help.

    _commandText = "UPDATE [dbo].[ControlParms] SET  WHERE [Device] = @Device; SELECT @Device AS id"

    base {System.SystemException} = {"Unable to cast object of type 'System.Data.SqlClient.SqlInternalConnectionTds' to type 'System.Data.SqlClient.SqlInternalConnectionSmi'."}

    SqlDataProvider.cs Line 461

    The SET in the SQL didn't contain any of the passed values, yet I can see the object when debugging the call.

    Please help.
    Dan

     

     

     

    If you're going to look back and laugh... You might as well laugh now!

  • 05-24-2008 11:30 PM In reply to

    Re: Help with Repository Patterm SQL update.

     

    I have come across the same problem.

    Have you checked RepObj.IsDirty or RepObj.DirtyColumns.Count ?

    I resolved the problem in my case by:

     if Obj.IsDirty then DB.Save(Obj)

     

  • 05-25-2008 2:43 AM In reply to

    Re: Help with Repository Patterm SQL update.

    Hmmm I know Eric added some love to this bug - so did I. Can you get the latest source and tell me if this happens again?

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

  • 05-25-2008 3:05 PM In reply to

    • DanKline
    • Top 50 Contributor
    • Joined on 12-13-2006
    • West Bend, WI
    • Posts 46

    Re: Help with Repository Patterm SQL update.

     Thanks for getting back to me.  I had tried updating and recompiling yesterday afternoon, following your line of logic.  Here's what I saw:

    There was no change, however, even when not using the repository pattern, the query command still lacked any population of the SET section of the SQL query.   No matter what I tried, DB.Save, Object.Update, they all failed exactly the same way.  Stepping through the code, I could see where all the columns were parsed and collected, but I couldn't pin down the exact location where the SET location was built or concatenated to the query.

    I backed down to 2.0.3 and everything is working perfectly, which indicates, as I expected, that there were no issues outside the Subsonic assemblies.

    Let me know if there is anything I can do to provide more help. - Dan

    If you're going to look back and laugh... You might as well laugh now!

  • 05-25-2008 11:22 PM In reply to

    • DanKline
    • Top 50 Contributor
    • Joined on 12-13-2006
    • West Bend, WI
    • Posts 46

    Re: Help with Repository Patterm SQL update.

    Reply |Contact |Answer

     I've recompiled the latest build 442 and deleted all my generated classes, rebuilt my Tools shorcut in VS2008 to point to the new build of Sonic.exe and regenerated the DAL.  After a code cleanup and recompile, everything seems to work again.

    dan

    If you're going to look back and laugh... You might as well laugh now!

Page 1 of 1 (5 items) | RSS