FirstOrDefault

public static class QueryOverExtensions
    {
        public static T FirstOrDefault<T, U>(this IQueryOver<T, U> queryOver)
            where T : class
            where U : class
        {
            return queryOver.Take(1).SingleOrDefault();
        }
    }
Example:
public class TeamEmployeeRepository : Repository<TeamEmployee>, ITeamEmployeeRepository
{
    public TeamEmployee GetFirstEmployee(string name)
    {
        return GetSession().QueryOver<TeamEmployee>()
            .Where(x => x.Name == name)
            .FirstOrDefault();
    }
}

Description

First or default extension method for NHibernate 3.0 and its new query API QueryOver.

Details

Double click on the code to select all.

 

;