我在HQL中有选择:
Dim query As IQuery = sessao.CreateQuery("SELECT PS.PseObs, P.PacNome " +
"FROM PacientesServicos AS PS INNER JOIN PS.Pacientes AS P " +
"INNER JOIN PS.Servicos AS S " +
"INNER JOIN PS.Usuarios AS U " +
"WHERE PS.Pacientes.PacNome like :nome")
query.SetParameter("nome", "HA%")
query.SetMaxResults(5)
Dim Listagem As IList = query.List
Return Listagem
我不知道将此列表放在gridview.datasource中。我尝试修改gridview的列,但没有找到datafield。当我使用select属性其他对象时,name属性是否不同?但是当我删除SELECT时,我可以放入gridview.datasource。
...
<asp:templatefield headertext="Pacientes">
<itemtemplate>
<asp:label id="Id"
Text= '<%# Eval("Pacientes.PacNome") %>'
runat="server"/>
</itemtemplate>
</asp:templatefield>
<asp:boundfield headertext="Observações" datafield="PseObs" ControlStyle-Width = "600" />
拜托,我需要帮助。我不知道。 我想得到Ilist并直接输入gridview.datasource,
我需要提问。
答案 0 :(得分:0)
我用构造函数创建了一个类。 我的HQL吼叫:
Dim query As IQuery = sessao.CreateQuery("SELECT New Teste(P.PacNome,PS.PseObs) " +
"FROM PacientesServicos AS PS INNER JOIN PS.Pacientes AS P " +
"INNER JOIN PS.Servicos AS S " +
"INNER JOIN PS.Usuarios AS U " +
"WHERE PS.Pacientes.PacNome like :nome")
query.SetParameter("nome", "HALL%")
Dim Listagem As IList(Of Teste) = query.List(Of Teste)()
创建的类Teste:
Public Class Teste
Private nome_ As String
Private obs_ As String
Public Sub New(ByVal nome As String, ByVal obs As String)
Me.nome_ = nome
Me.obs_ = obs
End Sub
Public Property Nome As String
Get
Return nome_
End Get
Set(ByVal value As String)
nome_ = value
End Set
End Property
Public Property Obs As String
Get
Return obs_
End Get
Set(ByVal value As String)
obs_ = value
End Set
End Property
End Class
结束命名空间
我必须创建teste.hbm.xml
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Modelo" namespace="Modelo.Cidadania.Modelo" > <import class="Teste"/> </hibernate-mapping>