Recent Commits to RefactoringToJQuery:master


Refactoring to DetachedNameQuery

The consequence of hiding the NHibernate ISession type from the client code is that I now have to rely on inline SQL which kind of makes me queasy. But this feeling is temporary because I can use a feature of NHibernate called DetachedNameQuery to achieve the following:

IRepository repository = new NHibernateRepository();
IDetachedQuery query = new DetachedNamedQuery("GetMaxTaskId");
ITask task = repository.Find<Task>(query);

GetMaxTaskId is defined in my NHibernate mapping file, Task.hbm.xml.

The entry takes the following form:

<query name ="GetMaxTaskId">
select max(task.Id) from Task task

1 comment:

Taiwanigloo said...

Good work !!!
very interesting articles!

Happy New Year


Test driving ASP.NET MVC 5 with the Entity Framework Code First

The great advantage of MVC Code First is the automated code generation tools. We took a test drive of these features by developing a small ...