久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <bdo id='YQd7U'></bdo><ul id='YQd7U'></ul>
    1. <i id='YQd7U'><tr id='YQd7U'><dt id='YQd7U'><q id='YQd7U'><span id='YQd7U'><b id='YQd7U'><form id='YQd7U'><ins id='YQd7U'></ins><ul id='YQd7U'></ul><sub id='YQd7U'></sub></form><legend id='YQd7U'></legend><bdo id='YQd7U'><pre id='YQd7U'><center id='YQd7U'></center></pre></bdo></b><th id='YQd7U'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YQd7U'><tfoot id='YQd7U'></tfoot><dl id='YQd7U'><fieldset id='YQd7U'></fieldset></dl></div>

    2. <legend id='YQd7U'><style id='YQd7U'><dir id='YQd7U'><q id='YQd7U'></q></dir></style></legend>
      <tfoot id='YQd7U'></tfoot>

      1. <small id='YQd7U'></small><noframes id='YQd7U'>

        使用 c# 驅動程序將字典插入 MongoDB

        Insert Dictionary into MongoDB with c# driver(使用 c# 驅動程序將字典插入 MongoDB)
        <legend id='JtZEs'><style id='JtZEs'><dir id='JtZEs'><q id='JtZEs'></q></dir></style></legend>

        <i id='JtZEs'><tr id='JtZEs'><dt id='JtZEs'><q id='JtZEs'><span id='JtZEs'><b id='JtZEs'><form id='JtZEs'><ins id='JtZEs'></ins><ul id='JtZEs'></ul><sub id='JtZEs'></sub></form><legend id='JtZEs'></legend><bdo id='JtZEs'><pre id='JtZEs'><center id='JtZEs'></center></pre></bdo></b><th id='JtZEs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JtZEs'><tfoot id='JtZEs'></tfoot><dl id='JtZEs'><fieldset id='JtZEs'></fieldset></dl></div>
        • <bdo id='JtZEs'></bdo><ul id='JtZEs'></ul>

              <small id='JtZEs'></small><noframes id='JtZEs'>

                <tfoot id='JtZEs'></tfoot>

                    <tbody id='JtZEs'></tbody>
                  本文介紹了使用 c# 驅動程序將字典插入 MongoDB的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我無法預測我的 MongoDB 文檔將包含哪些字段.所以我不能再用 BsonID 類型的 _id 字段創建對象.我發現創建一個 Dictionary (HashTable) 并在其中添加我的 DateTime 和 String 對象非常方便,我需要多少次都可以.

                  I am in a situation where I can't predict which fields my MongoDB document is going to have. So I can no longer create an object with an _id field of type BsonID. I find it very convenient to create a Dictionary (HashTable) and add my DateTime and String objects inside, as many times as I need it.

                  然后我嘗試將生成的 Dictionary 對象插入 MongoDb,但默認序列化失敗.

                  I then try to insert the resulting Dictionary object into MongoDb, but default serialization fails.

                  這是我的 HashTable 類型對象(類似于字典,但里面有不同的類型):

                  Here's my object of Type HashTable (like a Dictionary, but with varied types inside):

                  { "_id":"",
                  "metadata1":"asaad",
                  "metadata2":[],
                  "metadata3":ISODate("somedatehere")}
                  

                  我得到的驅動程序的錯誤是:

                  And the error from the driver I get is:

                  Serializer DictionarySerializer 期望 DictionarySerializationOptions 類型的序列化選項,而不是 DocumentSerializationOptions

                  Serializer DictionarySerializer expected serialization options of type DictionarySerializationOptions, not DocumentSerializationOptions

                  我用谷歌搜索了它,但找不到任何有用的東西.我做錯了什么?

                  I googled it, but couldn't find anything useful. What am I doing wrong?

                  推薦答案

                  驅動需要能夠找到_id字段.您可以創建一個只有兩個屬性的 C# 類:Id 和 Values.

                  The driver needs to be able to find the _id field. You could create a C# class that has just two properties: Id and Values.

                  public class HashTableDocument
                  {
                      public ObjectId Id { get; set; }
                      [BsonExtraElements]
                      public Dictionary<string, object> Values { get; set; }
                  
                  }
                  

                  請注意,我們必須使用 Dictionary<string, object>而不是哈希表.

                  Note that we have to use Dictionary<string, object> instead of Hashtable.

                  然后您可以使用如下代碼插入文檔:

                  You could then use code like the following to insert a document:

                  var document = new HashTableDocument
                  {
                      Id = ObjectId.GenerateNewId(),
                      Values = new Dictionary<string, object>
                      {
                          { "metadata1", "asaad" },
                          { "metadata2", new object[0] },
                          { "metadata3", DateTime.UtcNow }
                      }
                  };
                  collection.Insert(document);
                  

                  我們可以使用 MongoDB shell 來確認插入的文檔是否具有所需的形式:

                  We can use the MongoDB shell to confirm that the inserted document has the desired form:

                  > db.test.find().pretty()
                  {
                          "_id" : ObjectId("518abdd4e447ad1f78f74fb1"),
                          "metadata1" : "asaad",
                          "metadata2" : [ ],
                          "metadata3" : ISODate("2013-05-08T21:04:20.895Z")
                  }
                  >
                  

                  這篇關于使用 c# 驅動程序將字典插入 MongoDB的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)

                      <tbody id='HzUdq'></tbody>
                    • <small id='HzUdq'></small><noframes id='HzUdq'>

                      <legend id='HzUdq'><style id='HzUdq'><dir id='HzUdq'><q id='HzUdq'></q></dir></style></legend>
                        <bdo id='HzUdq'></bdo><ul id='HzUdq'></ul>
                        • <i id='HzUdq'><tr id='HzUdq'><dt id='HzUdq'><q id='HzUdq'><span id='HzUdq'><b id='HzUdq'><form id='HzUdq'><ins id='HzUdq'></ins><ul id='HzUdq'></ul><sub id='HzUdq'></sub></form><legend id='HzUdq'></legend><bdo id='HzUdq'><pre id='HzUdq'><center id='HzUdq'></center></pre></bdo></b><th id='HzUdq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HzUdq'><tfoot id='HzUdq'></tfoot><dl id='HzUdq'><fieldset id='HzUdq'></fieldset></dl></div>

                            <tfoot id='HzUdq'></tfoot>

                            主站蜘蛛池模板: 亚洲欧美日韩精品久久亚洲区 | av一级 | 超级乱淫av片免费播放 | 国产精品久久久久久久久久久新郎 | 97国产精品视频人人做人人爱 | 午夜在线| 一区二区免费看 | 成人毛片一区二区三区 | 国产亚洲一区二区三区 | 久久久久久亚洲欧洲 | 高清黄色网址 | 99视频在线免费观看 | av大片 | 成人国产精品久久 | 97超碰中文网 | www.99热这里只有精品 | www.一级毛片 | 99在线资源 | 日韩中文字幕一区二区 | 福利视频一区二区三区 | 日本精品视频 | 国产乱码高清区二区三区在线 | 亚洲国产精品久久久 | 九九九久久国产免费 | 亚洲一二三区在线观看 | 看毛片的网站 | 国产精品久久久久久久岛一牛影视 | 成人三级av | 国产精品视频网 | 欧美一级淫片免费视频黄 | 中文字幕乱码一区二区三区 | 国产成人亚洲精品自产在线 | 国产成人精品久久二区二区91 | 99视频久| 日韩在线高清 | 日韩在线视频播放 | 91精品国产91久久久久久吃药 | 国产成人一区二区三区久久久 | 久综合| 伊人超碰 | 精品一区二区三区av |