try it and see what happens. Are you using FNH or HBM for mappings? I
tried FNH and it works for getting things up and running, but I found
that once I wanted/needed to fine tune the mappings HBM was a better
choice. I also like using HBM to spike mapping features of NH. When I
want to understand what NH can do I strip out all the "noise". any
additional add-ons that are not required are removed.

On Jan 15, 2:57 am, Jonas <[email protected]> wrote:
> Hi there
>
> and thanks for the links :) In the second link ayende is apparently
> using a technique no longer supported from what I understand. I've
> made some progress since my last post and I've managed to implement
> the interceptor mentioned last in the article. I've also managed to
> apply the filter to the Address class, now I'm trying to add the same
> filter to the Adresses properties in the Student class. This is what I
> got sofar
>
> In the Contextinterceptor:
>
>             if(Context.Current != null)
>             {
>                 session.EnableFilter("customerfilter")
>                     .SetParameter("customerid",
> Context.Current.CustomerId)
>                     .SetParameter("regionalid",
> Context.Current.ReginalId);
>             }
>
> I'm also doing this
>
>             var filterParametersType = new Dictionary<string, IType>
> (1);
>             filterParametersType.Add("customerid",
> NHibernateUtil.Int32);
>             filterParametersType.Add("regionalid",
> NHibernateUtil.Int32);
>             nhCfg.AddFilterDefinition(new FilterDefinition
> ("customerfilter", ":customerid= customeridand :regionalid =
> regionalid", filterParametersType, false));
>
>             foreach (var mapping in nhCfg.ClassMappings)
>             {
>                 if (typeof(IContextAware).IsAssignableFrom
> (mapping.MappedClass))
>                 {
>                     mapping.AddFilter("customerfilter", ":customerid=
> customeridor :regionalid = regionalid");
>                 }
>             }
>
> That seem to be working, however calling Student.Addresses doesn't use
> the filter so from what I understand I need also to filter that
> specific relationship. Preferably I'd rather have a property in the
> Student class to be mapped to a filtered Address, so I can easily call
> Student.Adress. I have no idea how to do that though, don't think you
> can add a filter on a one-to-one relationship, so is that even
> possible?
-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.


Reply via email to