sapiens/SqlFu

Update generates wrong SQL where clause with generic function

Closed this issue · 1 comments

I have the following generic function

    private static void UpdateRowStatus<T>(DbConnection db, RowState resultingRowState, int rowId) where T : IRowWithState
    {
        var buildUpdateTable = db.Update<T>();
        buildUpdateTable.Set(p => p.Status, RowWithStateBase.ToString(resultingRowState));
        buildUpdateTable.Where(p => p.RowId == rowId);
        buildUpdateTable.Execute();
    }

where IRowWithState is

internal interface IRowWithState
{
    int RowId { get; set; }
    string Status { get; set; }
}

The usage of this function generates SQL where clause like this:

.... ( = @1) .... so it seems to me that the column name is not properly resolved.
Interestingly enough: The .Set creates valid SQL code.

The exact same code, used in a non-generic way, works like a charm.

It's interesting indeed, but at this point I don't have time to investigate it. If it works for Status it should work for RowId as well.