как использовать в заявлении в где предложение с помощью entitydatasource

1

Я хочу, чтобы полный dropdownlist из entitydatasource, но >>>

у меня проблема

CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)"

это мой код asp

<asp:DropDownList ID="doctorlist" runat="server" Width="172px" DataSourceID="EntityDataSource2" DataTextField="firstName" DataValueField="firstName">
</asp:DropDownList>
<asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=DentistEntities" DefaultContainerName="DentistEntities" CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)">
</asp:EntityDataSource>

но когда я скомпилирую, у меня была эта ошибка

Тип элемента 'Edm.Int32' и CollectionType 'Transient.collection [Transient.rowtype(doctorID, Edm.Int32 (Nullable = True, DefaultValue =))]' несовместимы. Выражение IN поддерживает только сущностные, скалярные и ссылочные типы. Рядом с предикатом WHERE, строка 1, столбец 69.

PLZ любая помощь

Спасибо

Теги:

1 ответ

3

Любой, имеющий такую же проблему, может попробовать это (обратите внимание на ключевое слово "VALUE" в подзапросе):

CommandText="SELECT d.[firstName] FROM DentistEntities.Doctors AS d WHERE d.[id] IN (SELECT VALUE s.[doctorID] FROM DentistEntities.DoctorsOfSections AS s WHERE s.[sectionID] = 2)"

Ещё вопросы

Сообщество Overcoder
Наверх
Меню