简体   繁体   中英

how to use in statement in where clause using entitydatasource

i want to full dropdownlist from entitydatasource but >>>

i have a problem

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)"

this my asp code

<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>

but when i compile i had this error

The element type 'Edm.Int32' and the CollectionType 'Transient.collection[Transient.rowtype(doctorID,Edm.Int32(Nullable=True,DefaultValue=))]' are not compatible. The IN expression only supports entity, scalar and reference types. Near WHERE predicate, line 1, column 69.

plz any help

thank you

任何有相同问题的人都可以尝试这一点(请注意子选择中的'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)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM