After several searches I finally found how to use my function on the same site of stackoverflow but I lost the link but I put the code for people that could help here
"searchforserchticketall" is my function in my database and
command.Parameters.Add (new Npgsql.NpgsqlParameter ("source", NpgsqlTypes.NpgsqlDbType.Integer)
{Value = source});
command.Parameters.Add (new Npgsql.NpgsqlParameter ("companyid", NpgsqlTypes.NpgsqlDbType.Integer) my two parameters next
command.ExecuteReader () to execute the function
using (var command = _context.Database.GetDbConnection().CreateCommand())
{
var function = "Transport.";
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "searchforserchticketall";
command.Parameters.Add(new Npgsql.NpgsqlParameter("source", NpgsqlTypes.NpgsqlDbType.Integer)
{ Value = source });
command.Parameters.Add(new Npgsql.NpgsqlParameter("compagnieid", NpgsqlTypes.NpgsqlDbType.Integer)
{ Value = compagnieid });
if (command.Connection.State == ConnectionState.Closed)
command.Connection.Open();
var res = command.ExecuteReader();
}