ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


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


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();


public class TeamEmployeeRepository : Repository<TeamEmployee>, ITeamEmployeeRepository
    public TeamEmployee GetFirstEmployee(string name)
        return GetSession().QueryOver<TeamEmployee>()
            .Where(x => x.Name == name)

Author: Mateusz Wajcowicz

Submitted on: 30 aug 2013

Language: C#

Type: Nhibernate.QueryOver

Views: 6662