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

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

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

      <legend id='zId19'><style id='zId19'><dir id='zId19'><q id='zId19'></q></dir></style></legend>

    1. <tfoot id='zId19'></tfoot>
      • <bdo id='zId19'></bdo><ul id='zId19'></ul>

        插入一個 IEnumerable&lt;T&gt;帶有 Dapper 錯誤的

        Inserting an IEnumerablelt;Tgt; collection with Dapper errors out with quot;class is not supported by Dapper.quot;(插入一個 IEnumerablelt;Tgt;帶有 Dapper 錯誤的集合,帶有“Dapper 不支持類.) - IT屋-程序員軟件開發技術
          <i id='YMllU'><tr id='YMllU'><dt id='YMllU'><q id='YMllU'><span id='YMllU'><b id='YMllU'><form id='YMllU'><ins id='YMllU'></ins><ul id='YMllU'></ul><sub id='YMllU'></sub></form><legend id='YMllU'></legend><bdo id='YMllU'><pre id='YMllU'><center id='YMllU'></center></pre></bdo></b><th id='YMllU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YMllU'><tfoot id='YMllU'></tfoot><dl id='YMllU'><fieldset id='YMllU'></fieldset></dl></div>

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

                <tbody id='YMllU'></tbody>
              • <bdo id='YMllU'></bdo><ul id='YMllU'></ul>
                <legend id='YMllU'><style id='YMllU'><dir id='YMllU'><q id='YMllU'></q></dir></style></legend><tfoot id='YMllU'></tfoot>
                • 本文介紹了插入一個 IEnumerable&lt;T&gt;帶有 Dapper 錯誤的集合,帶有“Dapper 不支持類".的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  是的,這里有問題和這里了解如何使用 dapper-dot-net 插入記錄.然而,這些答案雖然內容豐富,但似乎并沒有為我指明正確的方向.情況如下:將數據從 SqlServer 移動到 MySql.將記錄讀入 IEnumerable<WTUser> 很容易,但我只是在插入時沒有得到任何東西.一、'移動記錄代碼':

                  Yep, there are questions here and here about how to insert records with dapper-dot-net. However, the answers, while informative, didn't seem to point me in the right direction. Here is the situation: moving data from SqlServer to MySql. Reading the records into an IEnumerable<WTUser> is easy, but I am just not getting something on the insert. First, the 'moving records code':

                  //  moving data
                  Dim session As New Session(DataProvider.MSSql, "server", _
                                             "database")
                  
                  Dim resources As List(Of WTUser) = session.QueryReader(Of WTUser)("select * from tbl_resource")
                  
                  
                  session = New Session(DataProvider.MySql, "server", "database", _
                                        "user", "p@$$w0rd")
                  
                  //    *edit* - corrected parameter notation with '@'
                  Dim strInsert = "INSERT INTO tbl_resource (ResourceName, ResourceRate, ResourceTypeID, ActiveYN) " & _
                                  "VALUES (@ResourceName, @ResourceRate, @ResourceType, @ActiveYN)"
                  
                  Dim recordCount = session.WriteData(Of WTUser)(strInsert, resources)
                  
                  //  session Methods
                      Public Function QueryReader(Of TEntity As {Class, New})(ByVal Command As String) _
                                                                              As IEnumerable(Of TEntity)
                          Dim list As IEnumerable(Of TEntity)
                  
                          Dim cnn As IDbConnection = dataAgent.NewConnection
                          list = cnn.Query(Of TEntity)(Command, Nothing, Nothing, True, 0, CommandType.Text).ToList()
                  
                          Return list
                      End Function
                  
                      Public Function WriteData(Of TEntity As {Class, New})(ByVal Command As String, ByVal Entities As IEnumerable(Of TEntity)) _
                                                                            As Integer
                          Dim cnn As IDbConnection = dataAgent.NewConnection
                  
                          //    *edit* if I do this I get the correct properties, but no data inserted
                          //Return cnn.Execute(Command, New TEntity(), Nothing, 15, CommandType.Text)
                  
                          //    original Return statement
                          Return cnn.Execute(Command, Entities, Nothing, 15, CommandType.Text)
                      End Function
                  

                  cnn.Query 和 cnn.Execute 調用 dapper 擴展方法.現在,WTUser 類(注意:列名從 SqlServer 中的WindowsName"更改為 MySql 中的ResourceName",因此兩個屬性指向同一個字段):

                  cnn.Query and cnn.Execute call the dapper extension methods. Now, the WTUser class (note: the column name changed from 'WindowsName' in SqlServer to 'ResourceName' in MySql, thus the two properties pointing to the same field):

                  Public Class WTUser
                      //    edited for brevity - assume the following all have public get/set methods
                      Public ActiveYN As String
                      Public ResourceID As Integer
                      Public ResourceRate As Integer
                      Public ResourceType As Integer
                      Public WindowsName As String
                      Public ResourceName As String
                  
                  End Class
                  

                  我收到來自 dapper 的異常:Dapper 不支持 WTUser."DataMapper(dapper)中的這個方法:

                  I am receiving an exception from dapper: "WTUser is not supported by Dapper." This method in DataMapper (dapper):

                      private static Action<IDbCommand, object> CreateParamInfoGenerator(Type OwnerType)
                      {
                          string dmName = string.Format("ParamInfo{0}", Guid.NewGuid());
                          Type[] objTypes = new[] { typeof(IDbCommand), typeof(object) };
                  
                          var dm = new DynamicMethod(dmName, null, objTypes, OwnerType, true); // << - here
                          //    emit stuff
                  
                          //    dm is instanced, now ...
                          foreach (var prop in OwnerType.GetProperties().OrderBy(p => p.Name))
                  

                  此時 OwnerType =

                  At this point OwnerType =

                  System.Collections.Generic.List`1[[CRMBackEnd.WTUser,CRMBE,版本=1.0.0.0,文化=中性,PublicKeyToken=null]], mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089

                  System.Collections.Generic.List`1[[CRMBackEnd.WTUser, CRMBE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                  似乎 OwnerType 應該是 CRMBackEnd.WTUser ...而不是 List ... ???因為正在發生的事情是正在迭代集合屬性:計數、容量等.我錯過了什么?

                  It seems like OwnerType should be CRMBackEnd.WTUser ... not List<CRMBackEnd.WTUser> ... ??? because what is happening is that the collection properties are being iterated: Count, Capacity, etc. What am I missing?

                  更新

                  如果我將 session.WriteData 修改為:

                  If I modified session.WriteData as:

                  Public Function WriteData(Of TEntity As {Class, New})(ByVal Command As String, _
                                                                        ByVal Entities As IEnumerable(Of TEntity)) _
                                                                        As Integer
                      Dim cnn As IDbConnection = dataAgent.NewConnection
                      Dim records As Integer
                  
                      For Each entity As TEntity In Entities
                          records += cnn.Execute(Command, entity, Nothing, 15, CommandType.Text)
                      Next
                  
                      Return records
                  End Function
                  

                  記錄被很好地插入......但我認為這不是必要的,例如:

                  records are inserted nicely ... but I didn't think this would be necessary given examples like:

                  connection.Execute(@"insert MyTable(colA, colB) values (@a, @b)",
                      new[] { new { a=1, b=1 }, new { a=2, b=2 }, new { a=3, b=3 } }
                    ).IsEqualTo(3); // 3 rows inserted: "1,1", "2,2" and "3,3"  
                  

                  ...來自 dapper-dot-net

                  推薦答案

                  我剛剛為此添加了一個測試:

                  I just added a test for this:

                  class Student
                  {
                      public string Name {get; set;}
                      public int Age { get; set; }
                  }
                  
                  public void TestExecuteMultipleCommandStrongType()
                  {
                      connection.Execute("create table #t(Name nvarchar(max), Age int)");
                      int tally = connection.Execute(@"insert #t (Name,Age) values(@Name, @Age)", new List<Student> 
                      {
                          new Student{Age = 1, Name = "sam"},
                          new Student{Age = 2, Name = "bob"}
                      });
                      int sum = connection.Query<int>("select sum(Age) from #t drop table #t").First();
                      tally.IsEqualTo(2);
                      sum.IsEqualTo(3);
                  }
                  

                  它像宣傳的那樣工作.我對 multi-exec 的工作方式進行了一些修改(所以它更快一點并且支持 object[]).

                  It works as advertised. I made a few amendments to the way multi-exec works (so its a tad faster and supports object[]).

                  我的猜測是您遇到了問題,因為您在 WTUser 上的所有字段上都缺少 getter 屬性.所有參數都必須具有讀取器屬性,我們不支持從字段中提取它,它需要一個復雜的解析步驟才能保持效率.

                  My guess is you were having issues cause you were missing a getter property on all you fields on WTUser. All params must have reader properties, we do not support pulling this from fields, it would require a complex parsing step to stay efficient.

                  導致問題的另一點是向 dapper 傳遞一個帶有不受支持的映射的參數.

                  An additional point that caused an issue is passing dapper a param with unsupported mapping.

                  例如,不支持以下類作為參數:

                  For example, the following class is not supported as a param:

                  class Test
                  {
                     public int Id { get; set; }
                     public User User {get; set;}
                  }
                  
                  cnn.Query("select * from Tests where Id = @Id", new Test{Id = 1}); // used to go boom 
                  

                  問題是 dapper 沒有解析 SQL,它假定所有的 props 都可以設置為參數,但無法解析 User 的 SQL 類型.

                  The issue is that dapper did not parse the SQL, it assumed all the props are settable as params but was unable to resolve the SQL type for User.

                  最新版本解決了這個問題

                  Latest rev resolves this

                  這篇關于插入一個 IEnumerable&lt;T&gt;帶有 Dapper 錯誤的集合,帶有“Dapper 不支持類".的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)

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

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

                            <tbody id='h8gMa'></tbody>
                            主站蜘蛛池模板: 久久久五月天 | 亚洲国产精品va在线看黑人 | 日本天堂视频在线观看 | 欧美成人视屏 | 91久久综合| 亚洲精品美女在线观看 | 欧洲亚洲一区二区三区 | 久久久国产精品视频 | 日韩亚洲一区二区 | 91精品久久久久久久久久入口 | 欧美一区中文字幕 | 国产精品久久av | 91精品久久久久久久 | 成人精品一区亚洲午夜久久久 | 亚洲视频精品 | 国产1区2区在线观看 | 福利片在线看 | av黄色片在线观看 | 韩日一区 | 一区二区三区免费在线观看 | 亚洲一区二区免费 | 精品国产黄色片 | 龙珠z在线观看 | 亚洲成人精品一区 | 久久伊人一区 | 欧美精品一区二区三区视频 | 黄色毛片在线看 | 国产伦精品一区二区三区四区视频 | 中文字幕日韩av | 亚洲97 | 毛片一区二区三区 | 国产精品一区二区不卡 | 狠狠干五月天 | 中文无码日韩欧 | 国产精品欧美一区二区三区 | 久久久精品高清 | 99久久婷婷国产亚洲终合精品 | av毛片免费 | 国产91在线播放 | 美女日皮网站 | 国产高清久久久 |