I want to pass a collection of ids to a stored procedure that will be mapped using NHibernate. This technique was introduced in Sql Server 2008 ( more info here => Table-Val
You can pass collections of values without the hassle.
Example:
var ids = new[] {1, 2, 3}; var query = session.CreateQuery("from Foo where id in (:ids)"); query.SetParameterList("ids", ids);
NHibernate will create a parameter for each element.