@ASP Developer , you could try the following code to check if Employee exists in the database.
public bool CheckEmployeeExists(int employeeId, string employeeName)
{
// Implement Dapper code here
var sql = "SELECT * FROM Emplpoyee";
using (var connection = new SqlConnection(connstr))
{
connection.Open();
var list = connection.Query<Employee>(sql).ToList();
var result = list.Any(i => i.Name==employeeName&&i.Id==employeeId);
return result;
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.