Created
October 6, 2014 11:07
-
-
Save DominicFinn/eb02ac2b3a5c0e9df81c to your computer and use it in GitHub Desktop.
Create Sql Query NHibernate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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