Skip to content

Instantly share code, notes, and snippets.

@tugcearar
Last active November 9, 2018 14:15
Show Gist options
  • Save tugcearar/da221b404120dc9a8d33f73efc97ce5b to your computer and use it in GitHub Desktop.
Save tugcearar/da221b404120dc9a8d33f73efc97ce5b to your computer and use it in GitHub Desktop.
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace MyFunctionApp
{
public static class DeactivateSomething
{
[FunctionName("DeactivateSomething")]
public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
{
var str = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(str))
{
conn.Open();
var text = "UPDATE [dbo].[SomeTable] SET [IsActive] = 0 WHERE [SomeDate] <= GetDate();";
using (SqlCommand cmd = new SqlCommand(text, conn))
{
var rows = await cmd.ExecuteNonQueryAsync();
Console.WriteLine($"{rows} güncellendi.");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment