Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ADO.NET, LINQ, Entity Framework, NHibernate, DAL, ORM [игнор отключен] [закрыт для гостей] / LINQ с exists - проблемма с запросом / 4 сообщений из 4, страница 1 из 1
13.08.2009, 20:27
    #36142994
Alkatraz
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
LINQ с exists - проблемма с запросом
Здравствуйте!

Столкнулся со следующей проблеммой в запросе:

Код: plaintext
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;

Выдает ошибку "Не задана ссылка на объект", хотя аналогичный
Код: plaintext
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;

Отрабатывает нормально.

В чем проблемма?
...
Рейтинг: 0 / 0
13.08.2009, 20:32
    #36143002
bured
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
LINQ с exists - проблемма с запросом
у тебя какое разрешение монитора?
...
Рейтинг: 0 / 0
13.08.2009, 20:35
    #36143005
bured
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
LINQ с exists - проблемма с запросом
Первый запрос ToList() попробуй
...
Рейтинг: 0 / 0
13.08.2009, 22:17
    #36143098
Alkatraz
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
LINQ с exists - проблемма с запросом
bured, это имеет значение?

Спасибо, работает!..
...
Рейтинг: 0 / 0
Форумы / ADO.NET, LINQ, Entity Framework, NHibernate, DAL, ORM [игнор отключен] [закрыт для гостей] / LINQ с exists - проблемма с запросом / 4 сообщений из 4, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]