Здравствуйте!
Столкнулся со следующей проблеммой в запросе:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
IQueryable<DatabaseEntities.Document> PersonIDList = from Document in Context.Document
where (Document.ActualPeriod == Period)
&& (Document.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (Document.PersonID.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (Document.PersonID.LastName.Equals(Convert.ToString(edLastName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edLastName.EditValue)))
&& (Document.PersonID.FirstName.Equals(Convert.ToString(edFirstName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edFirstName.EditValue)))
&& (Document.PersonID.MiddleName.Equals(Convert.ToString(edMiddleName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edMiddleName.EditValue)))
&& (Document.PersonID.DocumentNumber.Equals(Convert.ToString(edDocumentNumber.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edDocumentNumber.EditValue)))
&& (Document.PersonID.DocumentDate.Equals(DocumentDate) || DocumentDate == DateTime.MinValue)
&& (Document.PersonID.BirthDate.Equals(BirthDate) || BirthDate == DateTime.MinValue)
select Document;
IQueryable<DatabaseEntities.Person> PersonList = from Person in Context.Person
where (Person.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (from DocumentPersonRelation in Context.DocumentPersonRelation
where (DocumentPersonRelation.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& PersonIDList.Contains(DocumentPersonRelation.Document)
select DocumentPersonRelation.Person).Contains(Person)
select Person;
Выдает ошибку "Не задана ссылка на объект", хотя аналогичный
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
IQueryable<DatabaseEntities.Person> PersonList = from Person in Context.Person
where (Person.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (from DocumentPersonRelation in Context.DocumentPersonRelation
where (DocumentPersonRelation.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (from Document in Context.Document
where (Document.ActualPeriod == Period)
&& (Document.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (Document.PersonID.Deleted == false || Properties.Settings.Default.ShowDeleted)
&& (Document.PersonID.LastName.Equals(Convert.ToString(edLastName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edLastName.EditValue)))
&& (Document.PersonID.FirstName.Equals(Convert.ToString(edFirstName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edFirstName.EditValue)))
&& (Document.PersonID.MiddleName.Equals(Convert.ToString(edMiddleName.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edMiddleName.EditValue)))
&& (Document.PersonID.DocumentNumber.Equals(Convert.ToString(edDocumentNumber.EditValue)) || String.IsNullOrEmpty(Convert.ToString(edDocumentNumber.EditValue)))
&& (Document.PersonID.DocumentDate.Equals(DocumentDate) || DocumentDate == DateTime.MinValue)
&& (Document.PersonID.BirthDate.Equals(BirthDate) || BirthDate == DateTime.MinValue)
select Document).Contains(DocumentPersonRelation.Document)
select DocumentPersonRelation.Person).Contains(Person)
select Person;
Отрабатывает нормально.
В чем проблемма?