0
我试图SUM
使用NHibernate的HQL,但是当执行查询抛出异常A first chance exception of type 'NHibernate.Exceptions.GenericADOException' occurred in NHibernate.dll
和结果是不会返回。我怎么能这样做?如何在NHibernate HQL中使用SUM?
尝试。
public IList<Conta> findAllContasReceber() {
ISession _session = getSession();
IList<Conta> list = _session.CreateQuery("SELECT SUM(c.valorFinal) " +
"FROM Conta c " +
"WHERE (c.tipoConta = 1) AND (c.status = 0) " +
"GROUP BY c.dtVencimento, c.cliente " +
"ÖRDER BY c.dtVencimento ASC "
)
.List<Conta>();
return list;
}
实体
[Serializable]
public class Conta {
public virtual long id { set; get; }
public virtual Cliente cliente { set; get; }
public virtual String historico { set; get; }
public virtual DateTime dtLancamento { set; get; }
public virtual DateTime dtVencimento { set; get; }
public virtual decimal valorPagar { set; get; } //total vendas
public virtual decimal valorAcrescimo { set; get; } //total acrescimo
public virtual decimal valorFinal { set; get; } //total pagar
public virtual DateTime dtPagamento { set; get; }
public virtual int tipoConta { set; get; } //1 receber, 2 pagar
public virtual PlanoDeConta planoConta { set; get; }
public virtual int status { set; get; } //0 ativa, 1 fechada, 2 cancelada, 3 aguardando pagamento
public virtual Venda venda { set; get; }
public Conta() {
}
}
您选择退货号码列表(因为你选择SUM)。但是你说这是一个Conta的列表。将您的代码更改为'IList list = _session ...' –
Rob
数字列表,这是什么意思?我想要一个'IList'。 –
FernandoPaiva
如果你想要一个'List',为什么你选择'SUM(c.valorFinal)'而不是'c。*'? –
Rob