Пример #1
0
        static void Main(string[] args)
        {
            SqlConnection connection = new SqlConnection(@"Data Source = LENOVO - PC\HUMBERBRIDGING; Initial Catalog = JOB_PORTAL_DB;Integrated Security = True; ");

            using (connection)
            {
                connection.Open();

                string query = "select * from Applicant_Educations";

                SqlCommand cmd = new SqlCommand(query, connection);

                ApplicantEducation[] applicantEducations = new ApplicantEducation[1000];
                int index = 0;

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ApplicantEducation edu = new ApplicantEducation();
                    edu.Id         = (Guid)reader[0]; //[0]=["Id"]
                    edu.Applicant  = (Guid)reader["Applicant"];
                    edu.Major      = (string)reader["Major"];
                    edu.Start_Date = (DateTime)reader["Start_Date"];

                    applicantEducations[index] = edu;
                    index++;
                }
            }
        }
Пример #2
0
 private ApplicantEducationPoco TranslateFromProto(ApplicantEducation proto)
 {
     return(new ApplicantEducationPoco
     {
         Id = Guid.Parse(proto.Id),
         Applicant = Guid.Parse(proto.Applicant),
         Major = proto.Major,
         CertificateDiploma = proto.CertificateDiploma,
         StartDate = Convert.ToDateTime(proto.StartDate),
         CompletionDate = Convert.ToDateTime(proto.CompletionDate),
         CompletionPercent = (byte)proto.CompletionPercent
     });
 }