0

I have a class with students details , when i retrieve the data from database iam storing in data table , how to pass data table values to class ?

public class Student 
{  
    public int StudentId { get; set; }  
    public string StudentName { get; set; }  
    public string Address { get; set; }  
    public string MobileNo { get; set; }  
}   
Jakob Busk Sørensen
  • 5,599
  • 7
  • 44
  • 96
Anson Davis
  • 37
  • 10
  • [Entity Framework](https://msdn.microsoft.com/en-us/library/aa937723(v=vs.113).aspx) – fredrik Jun 11 '18 at 05:57
  • You have to be more specific, as there are many ways to accomplish this. Entity Framework is one way. Another one is [Dapper](http://dapper-tutorial.net/dapper) (which I find simpler). You can also do it completely manually if you want. – Jakob Busk Sørensen Jun 11 '18 at 05:59
  • If you're getting the data via an SQL query, it's better to construct the list by iterating the `SqlDataReader` than to add the extra overhead of a `DataTable`. – ProgrammingLlama Jun 11 '18 at 05:59
  • Just to be clear, I did not vote to close it as duplicate (but 'to broad'). I do not think this is a duplicate of the question @s-akbari selected. – fredrik Jun 11 '18 at 06:02

0 Answers0