Not sure if I got your question, but I found the best way, IMHO, is to
do it as a query.

session.CreateSQLQuery("exec dbo.[SP_MyStoredProc]
@CustomerId=:CustomerId, @OtherParam=:OtherParam")
                .AddEntity(typeof(SpecialResultsEntity))
                .SetString("CustomerId", customerId)
                .SetBoolean("OtherParam", false)
                .List<SpecialResultsEntity>();

You must create a mapping specifically for the SpecialResultsEntity.
public sealed class SpecialResultsEntityMap :
ClassMap<SpecialResultsEntity>
{
        public SpecialResultsEntityMap()
        {
            ReadOnly();

            Id(x => x.ResultId)
                .GeneratedBy.Assigned();

            Map(x => x.Value1)
                .Not.Nullable();

            Map(x => x.Value2)
                .Not.Nullable();

            References(x => x.Customer, "CustomerId")
                 .Not.Nullable()
                 .Fetch.Join()
                 .NotFound.Exception();
        }
}

All entities and references will be inflated by NHibernate.

Joe


On Sep 13, 5:03 pm, Tim Scott <[email protected]> wrote:
> Is there any way to map a (read only) collection to a stored procedure
> with FNH?  The best I can tell it's done with <loader> referencing a
> <sql-query>, but the FNH wiki says those are not supported.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to