Dapper for delete Tables in Dotnet core
using Dapper;
using System;
using System.Data.SqlClient;
public class Program
{
private static string connectionString = "YourConnectionStringHere";
public static void Main()
{
using (var connection = new SqlConnection(connectionString))
{
connection.Open();
var userId = 1;
var sql = "DELETE FROM Users WHERE Id = @Id";
var affectedRows = connection.Execute(sql, new { Id = userId });
Console.WriteLine($"Number of rows deleted: {affectedRows}");
}
}
}
Comments
Post a Comment