Fastest way to map result of SqlDataReader to object

后端 未结 11 1072
花落未央
花落未央 2021-02-04 08:49

I\'m comparing materialize time between Dapper and ADO.NET and Dapper. Ultimately, Dapper tend to faster than ADO.NET, though the first time a given fetch query was executed

11条回答
  •  离开以前
    2021-02-04 09:05

    I love that the most upvoted answer mentions @MarkGravel and his FastMember. But if you're already using Dapper, which is also a component of his, you can use Dapper's GetRowParser like this:

    var parser = reader.GetRowParser(typeof(MyObject));
    
    while (reader.Read())
    {
        var myObject = parser(reader);
    }
    

提交回复
热议问题