我需要检索MongoDB中我的集合中的所有文档,但我无法弄清楚如何.我已经宣布我的'收藏'像这样 -
private static IMongoCollection<Project> SpeCollection = db.GetCollection<Project>("collection_Project");
Run Code Online (Sandbox Code Playgroud)
我遵循的是在解释这个 MongoDB的教程.我根据自己的需要调整了它,比如 -
var documents = await SpeCollection.Find(new Project()).ToListAsync();
Run Code Online (Sandbox Code Playgroud)
但是,我一直有以下错误 -
MongoDB.Driver.IMongoCollection没有'Find'的定义和扩展方法[superlong stuff]的最佳覆盖.查找包含无效的参数.
我使用Robomongo创建了两个集合:collection_Project包含这样的文档
{
"_id" : ObjectId("5537ba643a45781cc8912d8f"),
"_Name" : "ProjectName",
"_Guid" : LUUID("16cf098a-fead-9d44-9dc9-f0bf7fb5b60f"),
"_Obj" : [
]
}
Run Code Online (Sandbox Code Playgroud)
我用这个函数创建的
public static void CreateProject(string ProjectName)
{
MongoClient client = new MongoClient("mongodb://localhost/TestCreationMongo");
var db = client.GetServer().GetDatabase("TestMongo");
var collection = db.GetCollection("collection_Project");
var project = new Project
{
_Name = ProjectName,
_Guid = Guid.NewGuid(),
_Obj = new List<c_Object>()
};
collection.Insert(project);
}
Run Code Online (Sandbox Code Playgroud)
和collection_Object包含这样的文档
{
"_id" : ObjectId("5537ba6c3a45781cc8912d90"),
"AssociatedProject" : "ProjectName",
"_Guid" : LUUID("d0a5565d-a0aa-7a4a-9683-b86f1c1de188"),
"First" : 42,
"Second" : 1000
}
Run Code Online (Sandbox Code Playgroud)
我用这个函数创建的
public static void CreateObject(c_Object ToAdd)
{ …Run Code Online (Sandbox Code Playgroud) 我已经在我的应用程序中实现了 google recaptcha v3 并且我非常有信心它正在工作(在测试它时我得到了我期望的响应)。然而,我只是一个简单的人,我想通过模拟机器人行为来测试我的代码。通过使用扩展名“Modify Headers for Google Chrome”修改标题,它可以与recaptcha v2一起使用,但在这种情况下,我得到的分数与普通人类标题相同。
这是预期的结果吗?
这是一个意外的结果吗?我写的东西有问题吗?
或者是否有另一个更好的工具来模拟机器人?
我在删除列表中的重复引用时遇到问题.
我有这个清单
List<SaveMongo> toReturn
Run Code Online (Sandbox Code Playgroud)
我的班级SaveMongo看起来像这样
public class SaveMongo
{
public ObjectId _id { get; set; }
public DateTime date { get; set; }
public Guid ClientId { get; set; }
public List<TypeOfSave> ListType = new List<TypeOfSave>();
public List<ObjectId> ListObjSave = new List<ObjectId>();
public SaveMongo()
{ }
}
Run Code Online (Sandbox Code Playgroud)
每当我想在列表中添加元素时,我都使用以下代码
public static fctName(BsonDocument doc)
{
toReturn.Add(AddingSaveMongo(doc.GetValue("_id")));
}
public static SaveMongo AddingSaveMongo(BsonValue ObjValue)
{
foreach (SaveMongo doc in SpeCollection.FindAll())
{
foreach (var id in doc.ListObjSave)
{
if (id == ObjValue)
return (doc);
} …Run Code Online (Sandbox Code Playgroud) I am trying to set the color of a given cell with the color of another cell (that is already colored in the template.
But worksheet.Cells[row, col].Style.Fill.BackgroundColor doesn't seem to have a getproperty.
Is it possible to do that or do I have to find the exact hexdecimal code of the color on the internet ?
EDIT
using the code in the answer, I get that error (it is written in French but it translate with what I wrote …