Skip to content

Instantly share code, notes, and snippets.

@alimozdemir
Created June 7, 2020 15:53
Show Gist options
  • Save alimozdemir/681362a5488da4f9d36981abf61d0ea0 to your computer and use it in GitHub Desktop.
Save alimozdemir/681362a5488da4f9d36981abf61d0ea0 to your computer and use it in GitHub Desktop.
[HttpPatch]
public async Task Patch([FromODataUri] int key, Delta<vw_Song> delta)
{
var changedProps = delta.GetChangedPropertyNames();
var instance = delta.GetInstance();
var updateDict = new Dictionary<string, object>();
if (changedProps.Contains("Status"))
{
updateDict.Add("Status", instance.Status);
}
var q = new SqlKata.Query("Country_Songs")
.Where("SongId", key)
.AsUpdate(updateDict);
var result = _compiler.Compile(q);
await _db.Database.ExecuteSqlRawAsync(result.Sql, result.Bindings);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment