I need to get the files that are in a list and compare them with the files that are in a table in the database, and know if the amount of files in my list is the same amount as the table.
using Dapper;
public bool ValidarPessoas(List <int> pessoas) {
Dictionary < string, object > parametros = new Dictionary < string, object > ();
parametros.Add("@pessoas", pessoas);
parametros.Add("@quantidadePessoas", pessoas.Count);
var query = @ " SELECT CASE WHEN EXISTS
(
SELECT COUNT(ID) FROM dbo.[Pessoa] WHERE ID in (@pessoas) HAVING COUNT(Pessoa.ID) = @quantidadePessoas
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT)
END ";
string strConexao = ConfigurationManager.ConnectionStrings["conexao"].ConnectionString;
using(var sqlConnection = new SqlConnection(strConexao))
{
return sqlConnection.QueryFirstOrDefault < bool > (query, parametros);
}
}
When I run this code, I get the error:
System.Data.SqlClient.SqlException: 'Incorrect syntax near', '.'