private void ImportOptionsData(DataTable optionsData)
        {
            var validColumnNames = new[] { "SBD", "NV1.N", "NV1.TH", "NV2.N", "NV2.TH",
                                                "NV3.N", "NV3.TH", "NV4.N", "NV4.TH"};
            var columnNames = from column in optionsData.Columns.Cast<DataColumn>()
                              select column.ColumnName;
            ValidateColumnNames(columnNames, validColumnNames);

            var entities = new Entities();
            entities.Configuration.AutoDetectChangesEnabled = false;

            int id = 0;
            foreach (DataRow dataRow in optionsData.Rows)
            {
                var option = OptionFromDataRow(dataRow);
                entities.Options.Add(option);

                id++;
                if (id % 777 == 776)
                {
                    entities.SaveChanges();
                    entities.Dispose();
                    entities = new Entities();
                    entities.Configuration.AutoDetectChangesEnabled = false;
                }
            }

            entities.SaveChanges();
            entities.Dispose();
        }
        private void ImportCandidatesData(DataTable candidatesData)
        {
            var validColumnNames = new[] { "SBD", "HoTen", "NgaySinh", "KV", "DT", "UT",
                "Toan", "Van", "Ly", "Hoa", "Sinh", "Su", "Dia", "Anh", "Nga", "Phap", "Trung", "Duc", "Nhat" };
            var columnNames = from column in candidatesData.Columns.Cast<DataColumn>()
                              select column.ColumnName;
            ValidateColumnNames(columnNames, validColumnNames);

            var validSubjectNames = new[] { "Toán", "Văn", "Lý", "Hóa", "Sinh", "Sử", "Địa",
                                            "Anh", "Nga", "Pháp", "Trung", "Đức", "Nhật" };
            ValidateSubjectNames(validSubjectNames);

            var entities = new Entities();
            entities.Configuration.AutoDetectChangesEnabled = false;

            int id = 0;
            foreach (DataRow dataRow in candidatesData.Rows)
            {
                var candidate = CandidateFromData(dataRow);
                entities.Candidates.Add(candidate);

                id++;
                for (int i = 0; i < 13; i++)
                {
                    int subjectID = i + 1;
                    var markString = (string)dataRow[6 + i];
                    if (markString == "NA")
                        continue;

                    var mark = MarkFromData(id, subjectID, markString);
                    entities.Marks.Add(mark);
                }

                if (id % 777 == 776)
                {
                    entities.SaveChanges();
                    entities.Dispose();
                    entities = new Entities();
                    entities.Configuration.AutoDetectChangesEnabled = false;
                }
            }

            entities.SaveChanges();
            entities.Dispose();
        }