Search code examples
c#sqlkata

SqlKata.Execution.XQuery' does not contain a definition for 'Update'


I am attempting to run the following SQLKata statement to update a row of data via a .NET Core Lambda function (AWS). See below:

                    var affected = db.Query(targetTable)
                        .WhereIn("magento_order_id", order.order_id.ToString())
                        .Update(new
                        {
                            order_picked_up = order.status
                        });

I am reasonably sure this statement was working earlier, until I placed it inside a for reach loop. Now I'm getting the following error:

SqlKata.Execution.XQuery' does not contain a definition for 'Update'

From the SQLKata documentation, their example doesn't look much different from mine except the use of Where instead of WhereIn (i've tried both)

int affected = db.Query("Books").Where("Id", 1).Update(new {
    Price = 18,
    Status = "active",
});

I can see that the IDE seems to think that .Update is still a part of the dynamic variable order.order_id.ToSTring() as when I hover over .Update it resolves to 'dynamic' instead of Query, but I'm unclear as to why.


Solution

  • My code

    SqlKata.Query query = db.Query("UserImage").Where("ImageId", 1);
    query.Update(new
         {
          UserId = 1,
          ImagePath = 'imagepath',
          ImageType = 'avata'
         });
    

    when place update after 'where' IDE show it is update method of dynamic object, not SqlKata.Query