Ayende @ Rahien

Unnatural acts on source code

Linq for NHibernate: Functions

Bobby Diaz is still producing some amazing stuff. The new addition is native support for SQL functions. Take a look at this code:

DateTime date = new DateTime(1960, 1, 1);

var query = ( from e in db.Employees
                   where db.Methods.Year(e.BirthDate) >= date.Year && db.Methods.Len(e.FirstName) > 4
                   select e.FirstName )
                   .Aggregate(
new StringBuilder(), (sb, name) => sb.Length > 0 ? sb.Append(", ").Append(name) : sb.Append(name));

Console.WriteLine("Birthdays after {0}:", date.ToString("yyyy"));
Console.WriteLine(query);

Check out Bobby's post for the full details. I am going to write a full overview of the current state of Linq for NHibernate soon. The situation so far is looking very nice.

Comments

Bobby Diaz
04/16/2007 06:18 AM by
Bobby Diaz

Just added another post with more sample queries:

http://blogs.magiconsoftware.com/blogs/bdiaz/archive/2007/04/15/linq-query-samples-2.aspx

Thanks for the props!

Bobby

Comments have been closed on this topic.