public void GetAllRecords() { using (var db = new CSharpFall2013Entities()) { var myContact = db.Contacts.Select(x => new Data.Models.Contact { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, DateOfBirth = x.DateOfBirth, Gender_Id = x.Gender_Id, Nationality_Id = x.Nationality_Id, EducationLevel_Id = x.EducationLevel_Id, CurrentOccupation_Id = x.CurrentOccupation_Id, CreatedDate = x.CreatedDate, CreatedBy = x.CreatedBy, UpdatedDate = x.UpdatedDate, UpdatedBy = x.UpdatedBy }); if (myContact != null) { this.Table1Count = Properties.Resources.Label_Table1 + myContact.Count(); foreach (var contact in myContact) { this.MyContactNameList.Add(new ContactName { Id = contact.Id, FirstName = contact.FirstName, LastName = contact.LastName, DateOfBirth = contact.DateOfBirth.ToShortDateString() }); } this.MyContactNameSelectedIndex = 0; } var genderList = db.Genders; if (genderList != null) { foreach (var gender in genderList) { this.GenderList.Add(gender.Id, gender.Value); } } var nationalityList = db.Nationalities; if (nationalityList != null) { foreach (var nationality in nationalityList) { this.NationalityList.Add(nationality.Id, nationality.Value); } } var educationLevelList = db.EducationLevels; if (educationLevelList != null) { foreach (var educationLevel in educationLevelList) { this.EducationLevelList.Add(educationLevel.Id, educationLevel.Value); } } var occupationList = db.Occupations; if (occupationList != null) { foreach (var occupation in occupationList) { this.CurrentOccupationList.Add(occupation.Id, occupation.Value); } } } }
public void GetAllRecords() { using (var db = new CSharpFall2013Entities()) { var table1Contact = db.Contacts.Select(x => new Data.Models.Contact { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, DateOfBirth = x.DateOfBirth, Gender_Id = x.Gender_Id, Nationality_Id = x.Nationality_Id, EducationLevel_Id = x.EducationLevel_Id, CurrentOccupation_Id = x.CurrentOccupation_Id, CreatedDate = x.CreatedDate, CreatedBy = x.CreatedBy, UpdatedDate = x.UpdatedDate, UpdatedBy = x.UpdatedBy }); if (table1Contact != null) { this.Table1Count = Properties.Resources.Label_Table1 + table1Contact.Count(); foreach (var contact in table1Contact) { this.Table1List.Add(contact); } } var table2Nationality = db.Nationalities.Select(x => new Data.Models.Nationality { Id = x.Id, Value = x.Value, CreatedDate = x.CreatedDate, UpdatedDate = x.UpdatedDate }); if (table2Nationality != null) { this.Table2Count = Properties.Resources.Label_Table2 + table2Nationality.Count(); foreach (var nationality in table2Nationality) { this.Table2List.Add(nationality); } } var table3EductationLevel = db.EducationLevels.Select(x => new Data.Models.EducationLevel { Id = x.Id, Value = x.Value, CreatedDate = x.CreatedDate, UpdatedDate = x.UpdatedDate }); if (table3EductationLevel != null) { this.Table3Count = Properties.Resources.Label_Table3 + table3EductationLevel.Count(); foreach (var educationLevel in table3EductationLevel) { this.Table3List.Add(educationLevel); } } var table4Occupation = db.Occupations.Select(x => new Data.Models.Occupation { Id = x.Id, Value = x.Value, CreatedDate = x.CreatedDate, UpdatedDate = x.UpdatedDate }); if (table4Occupation != null) { this.Table4Count = Properties.Resources.Label_Table4 + table4Occupation.Count(); foreach (var occupation in table4Occupation) { this.Table4List.Add(occupation); } } } }