Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created October 6, 2014 11:07
Show Gist options
  • Save DominicFinn/eb02ac2b3a5c0e9df81c to your computer and use it in GitHub Desktop.
Save DominicFinn/eb02ac2b3a5c0e9df81c to your computer and use it in GitHub Desktop.
Create Sql Query NHibernate
public class Service
{
public IEnumerable<Report> Report(DateTime start, DateTime end)
{
var results = unitOfWork.Session.CreateSQLQuery(@"
select r.id, r.number
from Report r
where r.Date between =:start and =:end
")
.SetParameter("start", start)
.SetParameter("end", end)
.List<object[]>()
.Select(x => new Report()
{
Id = x[0]
, Number = x[1]
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment