Showing posts with label Datatable to List in C# using Linq. Show all posts
Showing posts with label Datatable to List in C# using Linq. Show all posts

4 August 2013

Datatable to List in C# using Linq

Datatable to List in C# using Linq

//StudentDetails Class with Entity Details
 public class StudentDetails
    {
        public int StudentID { get; set; }
        public string StudentName { get; set; }
        public string ClassName { get; set; }
        public string Section { get; set; }
    }
  

//Dataaccess part, Microsoft Sqlhelper class  used
 public List GetStudentDetails(int studentID)
        {
            DataSet ds = new DataSet();
            SqlParameter[] SqlParam = null;
            SqlParam = new SqlParameter[1];
            SqlCommand SqlCmd = new SqlCommand();
            List objStud = new List();
            try
            {
                SqlParam[0] = new SqlParameter("@StudentID", SqlDbType.Int);
                SqlParam[0].Value = studentID;
                SqlHelper.FillDataset(DBconnection(), CommandType.StoredProcedure, "usp_Get_StudentDetails", ds, new string[] { "Display" }, SqlParam);
               
 objStud = ds.Tables[0].AsEnumerable().Select(data => new StudentDetails() { StudentID = (int)data["StudentID"], StudentName = (string)data["StudentName"], ClassName = (string)data["ClassName"], Section = (string)data["Section"] }).ToList();
                return objStud;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (ds != null)
                {
                    ds.Dispose();
                }
                objStud = null;
            }
        }


Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...