private IEnumerable GetFileDataSource()
{
string[] sep = new string[] { "\r\n" };
string[] nationalCodeList = NationalCode.Split(sep, StringSplitOptions.RemoveEmptyEntries);
Server.ScriptTimeout = 3000000;
dc.Database.SetCommandTimeout(3000000);
var result = from p in dc.JazbFiles
where (txtFileNo.Text == string.Empty || p.FileNo == Convert.ToInt32("0" + txtFileNo.Text))
where (cboHarfParvande.SelectedValue == "" || p.FileHarfID == Convert.ToInt32("0" + cboHarfParvande.SelectedValue))
where (!nationalCodeList.Any() || nationalCodeList.Contains(p.NationalCode))
where (txtIdentNo.Text == string.Empty || p.IdentNum == txtIdentNo.Text)
where (cboSex.SelectedValue == "-1" || p.SexID == Convert.ToInt32(cboSex.SelectedValue))
where (txtFName.Text == string.Empty || p.FirstName.Replace(" ", "").Contains(txtFName.Text.Replace(" ", "")))
where (txtLName.Text == string.Empty || p.LastName.Replace(" ", "").Contains(txtLName.Text.Replace(" ", "")))
where (txtFatherName.Text == string.Empty || p.FatherName.Replace(" ", "").Contains(txtFatherName.Text.Replace(" ", "")))
where (this.University.Count == 0 || p.FileEducations.Select(q => q.UniversityID).Any(t => this.University.Contains(t)))
where (this.UniversityType.Count == 0
|| p.FileEducations.Select(q => q.University.ParentItemID).Any(t => this.UniversityType.Contains(t))
|| p.FileEducations.Where(c => c.University.ParentItemID != null).Select(q => q.University.HierarchyParentItem.ParentItemID).Any(t => this.UniversityType.Contains(t)))
where (this.AcademicField.Count == 0
|| p.FileEducations.Select(q => q.AcademicFieldID).Any(t => this.AcademicField.Contains(t))
|| p.FileEducations.Where(c => c.AcademicFieldID != null).Select(q => q.AcademicField.ParentItemID).Any(t => this.AcademicField.Contains(t))
|| p.FileEducations.Where(c => c.AcademicField.ParentItemID != null).Select(q => q.AcademicField.HierarchyParentItem.ParentItemID).Any(t => this.AcademicField.Contains(t)))
where (this.EducationLevel.Count == 0 || p.FileEducations.Select(q => q.EducationLevelID).Any(t => this.EducationLevel.Contains(t)))
where (cboStatus.SelectedValue == "-1" || p.FileEducations.Any(q => q.StatusID == Convert.ToInt32(cboStatus.SelectedValue)))
where (cboReshtehTahsili.SelectedValue == "-1" || p.FileEducations.Select(q => q.AcademicField.ParentItemID).Distinct().Any(t => t == Convert.ToInt32(cboReshtehTahsili.SelectedValue)))
where (txtStartDate3.Text == string.Empty || p.FileEducations.Any(q => q.FinishDate.CompareTo(txtStartDate3.Text) >= 0))
where (txtFinishDate3.Text == string.Empty || p.FileEducations.Any(q => q.FinishDate.CompareTo(txtFinishDate3.Text) <= 0))
where (txtReceiveDate_Start.Text == string.Empty || p.FileEducations.Any(q => q.ReceiveDate.Substring(0, 10).CompareTo(txtReceiveDate_Start.Text) >= 0))
where (txtReceiveDate_End.Text == string.Empty || p.FileEducations.Any(q => q.ReceiveDate.Substring(0, 10).CompareTo(txtReceiveDate_End.Text) <= 0))
where (this.SarbaziNoe.Count == 0 || p.FileEducations.Select(q => q.SarbaziNoeID).Any(t => this.SarbaziNoe.Contains(t)))
where (this.SarbaziNoeKhedmat.Count == 0 || p.FileEducations.Select(q => q.SarbaziNoeKhedmatID).Any(t => this.SarbaziNoeKhedmat.Contains(t)))
where (!chkTarhElzam.Checked || p.FileEducations.Any(q => q.SarbaziTarhElzamAzTarikh != ""))
where (txtStartDate4.Text == string.Empty || p.FileEducations.Any(q => q.SarbaziTarikhAmrie.CompareTo(txtStartDate4.Text) >= 0))
where (txtFinishDate4.Text == string.Empty || p.FileEducations.Any(q => q.SarbaziTarikhAmrie.CompareTo(txtFinishDate4.Text) <= 0))
where (txtStartDate5.Text == string.Empty || p.FileEducations.Any(q => q.SarbaziPayeKhedmati.CompareTo(txtStartDate5.Text) >= 0))
where (txtFinishDate5.Text == string.Empty || p.FileEducations.Any(q => q.SarbaziPayeKhedmati.CompareTo(txtFinishDate5.Text) <= 0))
where (!chkWithoutDegree.Checked || !p.FileEducations.Any())
where (!chkFaghedEblagh.Checked || !p.FileEducations.Any(q => q.FileEducationEblaghs.Any(e => !e.Rejected)))
where (!chkFaghedMoafiat.Checked || !p.FileEducations.Any(q => q.MoafiatStatus != null && q.MoafiatStatus != "UnderReview"))
where (!chkFaghedPayamAvari.Checked || !p.FileEducations.Any(q => q.SarbaziNoeKhedmat != null && q.SarbaziNoeKhedmat.Qualifier == "PayamAvar"))
where (!chkAdamShomulEzafekhedmat.Checked || p.FileEducations.Any(q => q.AdamShomulEzafekhedmatAzTarikh != null))
orderby p.LastName, p.FirstName
select new
{
p.ID,
p.FirstName,
p.LastName,
p.IdentNum,
p.FatherName,
p.NationalCode,
p.FileNo,
FileHarfID = p.FileHarf != null ? p.FileHarf.Dsc : "",
ReligionID = p.Religion != null ? p.Religion.Dsc : "",
NationalityID = p.Nationality != null ? p.Nationality.Dsc : "",
MarriageStatusID = p.MarriageStatus != null ? p.MarriageStatus.Dsc : "",
SexID = p.Sex.Dsc,
p.FormerLastName,
p.IssuancePlaceNamex,
p.BirthDate,
p.ChildCount,
p.PostalCode,
p.Address,
p.Phone,
p.Mobile,
p.Email,
p.DepartureDate,
p.TarhDepartureDuration,
p.TadavomDepartureDuration,
p.TadavomCovid19DepartureDuration,
p.AllTadavomDepartureDuration,
p.TotalDepartureDuration,
p.SarbaziDuration,
TotalTarhDepartureDuration = (p.TotalDepartureDuration ?? 0) - (p.SarbaziDuration ?? 0),
};