Ignore public/internal fields for NHibernate proxy

前端 未结 5 2158
灰色年华
灰色年华 2021-02-12 19:07

I have some entity types that I would like to lazy load. However, they have some internal (assembly) fields they expose, but are not used outside that class. These fields are co

5条回答
  •  情深已故
    2021-02-12 19:25

    I reassembled NHibernate (easier than getting the source and rebuilding) and removed the code that errors on internal/public fields. LazyLoading appears to work just fine without that check. (Although, I'm new to NHibernate and so there are probably scenarios I don't know about.)

    Edit: Ah, there is a property, "use_proxy_validator" that will disable all validation checks. Good enough.

    Fluently.Configure()
        .ExposeConfiguration(fun cfg -> 
            cfg.Properties.Add("use_proxy_validator", "false"))...
    

提交回复
热议问题