Tags down


nhibernate interceptors with domain context

By : Mike
Date : October 17 2020, 11:12 AM
it should still fix some issue You can store the user in the current session (HttpContext.Session) or use thread local data. It can then be accessed by the listener. If you go for the thread local approach, you will need to set if for each request, for instance with an HttpModule. Not perfect, but that's how I've seen it done in java (not exactly the same, but a similar approach).
code :

Share : facebook icon twitter icon

NHibernate: Meaning of interceptors return value

By : Iceweasel
Date : March 29 2020, 07:55 AM
wish of those help I believe the return value should indicate if the state parameter has been changed in the interceptor method. You're right - it's a tough one to google at the moment - the NHibernate site moved recently and google doesn't seem to find as much useful info as it used to.

Add Interceptors through the web.config? NHibernate

By : Robert Mann
Date : March 29 2020, 07:55 AM
this one helps. I don't think it's supported but you can easily fetch and instantiate interceptors from a custom config section:
code :
NHibernate.Cfg.Configuration cfg = ...
var interceptors = (NameValueCollection) ConfigurationManager.GetSection("nhibernate.interceptors");
foreach (string k in interceptors)
    cfg.SetInterceptor((IInterceptor) Activator.CreateInstance(Type.GetType(k)));
<?xml version="1.0" encoding="utf-8" ?>
   <section name="nhibernate.interceptors" type="System.Configuration.NameValueSectionHandler, System" />
    <add key="MyApp.Interceptors.SomeInterceptor, MyApp" value=""/>
    <add key="MyApp.Interceptors.AnotherInterceptor, MyApp" value=""/>

Multiple interceptors in NHibernate

By : user3468833
Date : March 29 2020, 07:55 AM
seems to work fine The problem is not multiple interceptors. And the problem is not calling invocation.Proceed(). The problem is that you don't call invocation.Proceed() in your DataErrorInfoInterceptor when the method is not from IDataErrorInfo (it's correct in the linked article). Because of this, when you call some getter or setter, nothing happens.
Right now, you have something like this:
code :
if (invocation.Method.DeclaringType.Equals(typeof(IDataErrorInfo)))
    if (invocation.Method.Name.Equals("get_Item"))
        // some code
    else if (invocation.Method.Name.Equals("get_Error"))
        // more code
if (invocation.Method.DeclaringType.Equals(typeof(IDataErrorInfo)))
    if (invocation.Method.Name.Equals("get_Item"))
        // some code
    else if (invocation.Method.Name.Equals("get_Error"))
        // more code

Nhibernate interceptors not picking up properties of base class

By : lightstream
Date : March 29 2020, 07:55 AM
may help you . I'm converting from Fluent to Loquacious, and I've run in to an issue where my interceptors are not getting all the fields like I think they should. If I look at the OnSave function , you could make a base mapping class
code :
public class BaseAuditEntityMapping<T> : ClassMapping<T> where T: BaseAuditEntity
    ManyToOne(x => x.ModifiedByUser);
    Property(x => x.LastModifiedTime);

public class FooMap: BaseAuditEntityMapping<Foo>

NHibernate and interceptors - measuring/monitoring SQL round-trip times

By : amh
Date : March 29 2020, 07:55 AM
like below fixes the issue I had a similar problem. I wanted measure and log all queries that goes through NHibernate. What I did is I wrote a custom batching factory (in this case I work with oracle) but you can apply the same technique to any db:
1-) Implement batcher factory, (in this case I am extending existing factory)
code :
public class OracleLoggingBatchingBatcherFactory : OracleDataClientBatchingBatcherFactory
    public override IBatcher CreateBatcher(ConnectionManager connectionManager, IInterceptor interceptor)
        return new OracleLoggingBatchingBatcher(connectionManager, interceptor);
public class OracleLoggingBatchingBatcher : OracleDataClientBatchingBatcher, IBatcher
      .... // here override ExecuteNonQuery, DoExecuteBatch and ExecuteReader. 
           //You can do all kind of intercepting, logging or measuring here
           //If they are not overrideable just implement them and use "new" keyword if necessary
           //since we inherit IBatcher explicitly it will work polymorphically.
           //Make sure you call base implementation too or re-implement the method from scratch
    <property name="adonet.factory_class">OracleLoggingBatchingBatcherFactory, MyAssembly</property>
Related Posts Related Posts :
  • Is there any way in Linq To SQL to obtain the underlying (raw) SQL happening in a SubmitChanges() call?
  • page loads very slowly after its left idle
  • How to export current ASPX page to PDF
  • What is a Generic Handler in asp.net and its use?
  • Confused with asp.net controls and html controls
  • Are Active X for asp.net outdated? What other options do I have?
  • From asp.net code behind (aspx.cs) on the server how can I determine if Silverlight is installed on the client?
  • Is it possible to configure a location in Web.config to only allow local connections
  • How to set checked property of CheckBoxList items in aspx markup?
  • asp.net sessions lost when the page is reloaded (ispostback = false)
  • Request.QueryString[] does not return my desired value
  • ASP.NET Refrence to my local PC in users event log, why?
  • How to use a variable defined in code behind file in ASP.NET on inline code for the same page
  • Error: allowDefinition='MachineToApplication' beyond application level
  • ASP.NET Checkbox databinding to Byte datatype
  • Difference between axd and ashx handlers
  • Moving from WebForms to ASP.NET MVC
  • Cache the DTO or cache data from the expensive resource
  • Migrate Access to ASP.NET
  • Hyperlink in a Datalist
  • ASP.NET: Scheduled tasks
  • Is there a way to update a ViewModel in MVC2?
  • How to bind a function to "Click" event of a dynamically added ImageButton?
  • jQuery server side DOM manipulation
  • window.XMLHttpRequest is undefined in IE7/IE8
  • Detect whether the ie8 xss filter is enabled
  • I would like to convert Joomla CMS to ASP.net as there is no CMS like Joomla in .net. Would that be a good idea?
  • How Can I Use NUnit with ASP.NET Website (Not Web Project)?
  • Probing is not working Asp.net 2.0
  • How to handle this error gracefully in asp.net?
  • ASP.NET MVC - Ajaxified RenderAction
  • Context.Response.End() and Thread was being aborted
  • How to get Classes to expose the same Shared/Static method
  • Which version of Windows 7 for .NET Developers
  • Crystal Report Viewer - Programmatically restricting File Format options
  • Convert textarea text into valid html
  • What is the easiest set of tools to get started with Source Control, TDD, and CI for Microsoft.Net 2008/2010
  • Setting up IIS with System.Data.OracleClient
  • Running sites on "localhost" is extremely slow
  • No querystring logged in IIS log on "A potentially dangerous Request.QueryString value detected"
  • Quick way to pretty up a totally unstyled asp.net application
  • Edit and continue in ASP.NET web projects
  • Testing: I *want* to test web.config
  • ASP.NET UserControl not defined?
  • How can plain HTML controls be referenced from ASP.Net controls?
  • Is there a better .NET template system than XSLT?
  • Could not load type 'site._Default'
  • Asp.Net: Is it possible filtering a list in a content page by a value set in its master page?
  • ASP.NET How can I write a message on the screen without the end user removing it?
  • Examples of when to use PageAsyncTask (Asynchronous asp.net pages)
  • Is it possible to have a Conditional Compilation for ASP.NET comment?
  • VB.Net MailMessage text encoding issue
  • How to handle ASP.NET application error that occurs on application start and transfer & display error in MVC view?
  • ASP.NET coding for insert data
  • An Open Source Project Made With Nettiers
  • SQL Server 2005
  • What is machine config in asp.net
  • Does running a HTTPModule prevent IIS Logging?
  • How to retrieve xsl:output media-type value from xsl file via ASP.NET
  • How to get the selected Date from the calendar control?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org