Convert Table Data To List Using Reflection4 min read

In this blog, learn how to convert table data into list data using Reflection and LINQ. You can use the data passing from the server side to the client side.

Reflection

You can use Reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from existing object, and invoke its methods or access fields and properties. If you are using attributes in your code, Reflection enables you to access them.

It will provide object assemblies, modules, and types.

Model Properties

Create a simple variable in the model class in which you can use whatever data types that you want to.

Table Column

Create a table — but note that you must set the column name as the model properties. If there is a mismatch, then the name reflection will not work.

Conversion

If ADO.NET is used in this situation, then after the execution, the data will fill the dataset.

Convert the table into a list by using the extension ToList<> .

Reflection has created an instance of a property and data transfer from the table to the list that is provided below in the code.

Note: This scenario is useful when it comes to using ADO.NET.

Conclusion

In this blog, we have converted table data into a list using Reflection. If you have any questions, please tell me through the comments section.

Author Profile

Thiruppathi Rengasamy
I 'm a .Net Developer & Blogger. And also I'm working as senior software engineer in Microsoft Technologies for 5+ Years.I would like to spend my precious time in writing articles, research in .Net technologies and to learn new technologies.

Hits: 14