Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法反序列化';b声控文件';从BsonType';数组';例外情况_C#_Mongodb - Fatal编程技术网

C# 无法反序列化';b声控文件';从BsonType';数组';例外情况

C# 无法反序列化';b声控文件';从BsonType';数组';例外情况,c#,mongodb,C#,Mongodb,我在尝试将json字符串解析为BsonDocument时遇到了这个错误 public class Request : BsonDocument { [JsonProperty("_id")] public ObjectId Id { get; set; } [JsonProperty("idRequest")] public Guid IdRequest { get; set; }

我在尝试将json字符串解析为BsonDocument时遇到了这个错误

public class Request : BsonDocument
    {
        [JsonProperty("_id")]
        public ObjectId Id { get; set; }
        [JsonProperty("idRequest")]
        public Guid IdRequest { get; set; }
        [JsonProperty("json_request")]
        public string Request { get; set; }
        [JsonProperty("json_response")]
        public string Response { get; set; }
        [JsonProperty("dateRequest")]
        public DateTime DateRequest { get; set; }
        [JsonProperty("vendor")]
        public Guid VendorCode { get; set; }
        [JsonProperty("productCode")]
        public Guid ProductionCode { get; set; }
    }
c#代码:

我见过类似问题的各种答案,但我不明白我错在哪里

下午好

请向我们提供一个错误日志,以查看到底是什么问题,并查看此链接


看起来您对mongodb c#驱动程序的工作原理一无所知。请观看介绍性视频,如:
    var mongoDBRepo = new RequestRepository(_mongoDbContext, ApplicationConstant.COLLECTION_MONGODB);
Request _request = new Request
                        {
                            IdRequest  = request.IdRequest,
                            VendorCode = request.VendorCode,
                            ProductCode = request.ProductCode,
                            DateRequest  = request.DateRequest ,
                            Request = request.Request,
                            Response = request.Response
                        };
    
 var json = Newtonsoft.Json.JsonConvert.SerializeObject(_request);
    
 var document = BsonDocument.Parse(json); **=> This line raises the Exception**
    
 await mongoDBRepo.InsertOneAsync((Request)document);