Last active
November 9, 2018 14:15
-
-
Save tugcearar/da221b404120dc9a8d33f73efc97ce5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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