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

  • <legend id='LkCsI'><style id='LkCsI'><dir id='LkCsI'><q id='LkCsI'></q></dir></style></legend>

        <tfoot id='LkCsI'></tfoot>

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

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

        使用 Entity Framework 6 從 SQL Server 保存和檢索圖像

        Save and retrieve image (binary) from SQL Server using Entity Framework 6(使用 Entity Framework 6 從 SQL Server 保存和檢索圖像(二進(jìn)制))

              <tbody id='pOqFw'></tbody>

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

                <legend id='pOqFw'><style id='pOqFw'><dir id='pOqFw'><q id='pOqFw'></q></dir></style></legend>
                • <bdo id='pOqFw'></bdo><ul id='pOqFw'></ul>

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

                • <tfoot id='pOqFw'></tfoot>
                  本文介紹了使用 Entity Framework 6 從 SQL Server 保存和檢索圖像(二進(jìn)制)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我正在嘗試將位圖圖像保存到數(shù)據(jù)庫(kù)中

                  I am trying to save a bitmap image to database

                  Bitmap map = new Bitmap(pictureBoxMetroMap.Size.Width, pictureBoxMetroMap.Size.Height);
                  

                  我在數(shù)據(jù)類(lèi)型 binary 的數(shù)據(jù)庫(kù)中創(chuàng)建了一個(gè)列 imgcontent 但我的問(wèn)題是如何將此 bitmap (map) 轉(zhuǎn)換為二進(jìn)制數(shù)據(jù)?

                  I created a column imgcontent in the database with datatype binary but my problem is how can I convert this bitmap (map) to binary data?

                  我如何從數(shù)據(jù)庫(kù)中檢索數(shù)據(jù)?

                  And how can I retrieve data from database?

                  我用谷歌搜索了它,我發(fā)現(xiàn)了類(lèi)似的東西,但它不起作用:

                  I googled it and I found something like this but it didn't work:

                  byte[] arr;
                  ImageConverter converter = new ImageConverter();
                  arr = (byte[])converter.ConvertTo(map, typeof(byte[]));
                  

                  推薦答案

                  將圖像轉(zhuǎn)換為 byte[] 并將其存儲(chǔ)在數(shù)據(jù)庫(kù)中.

                  Convert the image to a byte[] and store that in the database.

                  將此列添加到您的模型中:

                  Add this column to your model:

                  public byte[] Content { get; set; }
                  

                  然后將您的圖像轉(zhuǎn)換為字節(jié)數(shù)組并像存儲(chǔ)任何其他數(shù)據(jù)一樣存儲(chǔ)它:

                  Then convert your image to a byte array and store that like you would any other data:

                  public byte[] ImageToByteArray(System.Drawing.Image imageIn)
                  {
                      using(var ms = new MemoryStream())
                      {
                          imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                      
                          return ms.ToArray();
                      }
                  }
                  
                  public Image ByteArrayToImage(byte[] byteArrayIn)
                  {
                       using(var ms = new MemoryStream(byteArrayIn))
                       {
                           var returnImage = Image.FromStream(ms);
                  
                           return returnImage;
                       }
                  }
                  

                  來(lái)源:將圖像轉(zhuǎn)換為字節(jié)數(shù)組的最快方法

                  var image = new ImageEntity()
                  {
                     Content = ImageToByteArray(image)
                  };
                  
                  _context.Images.Add(image);
                  _context.SaveChanges();
                  

                  當(dāng)你想取回圖像時(shí),從數(shù)據(jù)庫(kù)中獲取字節(jié)數(shù)組并使用 ByteArrayToImage 并使用 Image

                  When you want to get the image back, get the byte array from the database and use the ByteArrayToImage and do what you wish with the Image

                  當(dāng) byte[] 變大時(shí),這將停止工作.它適用于 100Mb 以下的文件

                  This stops working when the byte[] gets to big. It will work for files under 100Mb

                  這篇關(guān)于使用 Entity Framework 6 從 SQL Server 保存和檢索圖像(二進(jìn)制)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

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

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

                          • <legend id='TFtYZ'><style id='TFtYZ'><dir id='TFtYZ'><q id='TFtYZ'></q></dir></style></legend>

                            主站蜘蛛池模板: 欧美xxxx性| 手机av在线 | 中文字幕视频在线看5 | 久久最新 | 噜噜噜噜狠狠狠7777视频 | 国产精品一区二区三区四区 | 99热播放 | 国产精品久久久久久久久免费高清 | 成人性视频在线 | 亚洲中字在线 | 亚洲精品一区国产精品 | 国产精品久久久久久 | 男人久久天堂 | 羞羞的视频免费看 | av网站免费观看 | 国产精品久久久久久婷婷天堂 | av一二三四| 91社区在线观看播放 | 久久久久久亚洲精品 | 一级片免费观看 | 午夜合集 | 97国产爽爽爽久久久 | 毛片一级片 | 午夜影院在线 | 久久极品| 日韩在线一区二区三区 | 狠狠av | 97久久精品午夜一区二区 | 国产精品日韩欧美一区二区三区 | 亚洲h色 | 成人免费视屏 | 国产一区二区三区网站 | 美美女高清毛片视频免费观看 | 亚洲一区二区久久 | 成人精品国产一区二区4080 | 在线成人av| 毛片视频免费观看 | 欧美天堂| 欧美精品综合 | 亚洲一区中文 | 91久久久久久久久 |