Is there a way to easily convert a flat DataTable to a nested .NET object?

冷暖自知 提交于 2019-12-23 03:12:57

问题


I have a large hand tuned SQL query that returns a flat data table with many (>25) columns.

Currently, I manually convert that to a .NET object with three levels of nesting (i.e. an object which contains (among other properties) a list of further objects which contains (among other properties) a list of further objects.

Is there anything with the ease of something like AutoMapper which can convert a DataTable into a target .NET object, even if its nested?


回答1:


I am the original poster of this question.

It turns out that I was asking the wrong question: I should have been asking how to easily perform fast queries which map into a complex arrangement of POCOs.

I have posted the solution that worked perfectly for me, see How do I write one to many query in Dapper.Net? and the answer that references Dapper + Slapper.Automapper.



来源:https://stackoverflow.com/questions/30031223/is-there-a-way-to-easily-convert-a-flat-datatable-to-a-nested-net-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!