我自己也遇到过这个问题,但那是因为我忘记了它是如何完成的。这是我之前的代码:
public static string MakeRequest(string GetCountry, string GetTime, string Server, string Database)
{
var filter = Builders<RequestAccess>.Filter;
var getCountryfilter = filter.Eq(x => x.GetCountry, GetCountry);
var getTimefilter = filter.Eq(x => x.GetTime, GetTime);
var databasefilter = filter.Eq(x => x.Database, Database);
var serverfilter = filter.Eq(x => x.Servers, Server);
var makeRequest = RequestCollection.Find(filter.Or(getCountryfilter, getTimefilter, databasefilter, serverfilter)).ToList();
return makeRequest;
}
但下面的代码是正确的:)
public static List<RequestAccess> MakeRequest(string GetCountry, string GetTime, string Server, string Database)
{
var filter = Builders<RequestAccess>.Filter;
var getCountryfilter = filter.Eq(x => x.GetCountry, GetCountry);
var getTimefilter = filter.Eq(x => x.GetTime, GetTime);
var databasefilter = filter.Eq(x => x.Database, Database);
var serverfilter = filter.Eq(x => x.Servers, Server);
var makeRequest = RequestCollection.Find(filter.Or(getCountryfilter, getTimefilter, databasefilter, serverfilter)).ToList();
return makeRequest;
}
所以这意味着如果你想列出一些东西,那么不要在public static ...
:)中使用“字符串”