Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IList<Abastecimento> Resumo(DateTime dataInicio, DateTime dataFinal)
- {
- string hql = "SELECT NumCarroId, DtAbastecido FROM Abastecimento a WHERE a.DtAbastecido Between :dataInicial AND :dataFinal GROUP BY a.NumCarroId";
- IQuery query = session.CreateQuery(hql)
- .SetParameter("dataInicial", dataInicio)
- .SetParameter("dataFinal", dataFinal);
- return query.List<Abastecimento>();
- }
- CREATE TABLE [dbo].[Abastecimento] (
- [Id] INT IDENTITY (1, 1) NOT NULL,
- [DtAbastecido] DATETIME NULL,
- [Litro] INT NULL,
- [VlrUnit] DECIMAL (18, 2) NULL,
- [TotalGasto] DECIMAL (18, 2) NULL,
- [AutorId] INT NULL,
- [NumCarroId] INT NULL,
- [Km] INT NULL,
- [NomeProdutoId] INT NULL,
- [Km_Andado] INT NULL,
- PRIMARY KEY CLUSTERED ([Id] ASC),
- CONSTRAINT [FK84286500787E6DCB] FOREIGN KEY ([AutorId]) REFERENCES [dbo].[Usuario] ([Id]),
- CONSTRAINT [FK842865002F58EAD8] FOREIGN KEY ([NumCarroId]) REFERENCES [dbo].[Veiculo] ([Id]),
- CONSTRAINT [FK8428650023D2F9D9] FOREIGN KEY ([NomeProdutoId]) REFERENCES [dbo].[Compra] ([Id])
- );
- public class Abastecimento {
- public virtual int Id {
- get;
- set;
- }
- [Required]
- public virtual int Litro {
- get;
- set;
- }
- public virtual DateTime ? DtAbastecido {
- get;
- set;
- }
- public virtual decimal VlrUnit {
- get;
- set;
- }
- public virtual int Km {
- get;
- set;
- }
- public virtual decimal TotalGasto {
- get;
- set;
- }
- public virtual int Km_Andado {
- get;
- set;
- }
- public virtual Usuario Autor {
- get;
- set;
- }
- public virtual Compra NomeProduto {
- get;
- set;
- }
- public virtual Veiculo NumCarro {
- get;
- set;
- }
- }
- }
- select numCarroId, sum(valorGasto) gastos from Abastecimento
- where dataAbastecimento between '2017-05-21' and '2017-11-13'
- group by numCarroId
- public class Abastecimento {
- public virtual int Id {
- get;
- set;
- }
- [Required]
- public virtual int Litro {
- get;
- set;
- }
- public virtual DateTime ? DtAbastecido {
- get;
- set;
- }
- public virtual decimal VlrUnit {
- get;
- set;
- }
- public virtual int Km {
- get;
- set;
- }
- public virtual decimal TotalGasto {
- get;
- set;
- }
- public virtual int Km_Andado {
- get;
- set;
- }
- public virtual Usuario Autor {
- get;
- set;
- }
- public virtual Compra NomeProduto {
- get;
- set;
- }
- public virtual Veiculo NumCarro {
- get;
- set;
- }
- }
- }
- public IList < Abastecimento > Resumo(DateTime dataInicio, DateTime dataFinal) {
- string hql = "select a.NumCarro, sum(a.TotalGasto) gastos from Abastecimento a WHERE a.DtAbastecido Between :dataInicial AND :dataFinal GROUP BY a.NumCarro";
- IQuery query = session.CreateQuery(hql)
- .SetParameter("dataInicial", dataInicio)
- .SetParameter("dataFinal", dataFinal);
- return query.List < Abastecimento > ();
- }
Add Comment
Please, Sign In to add comment