Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3277156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:20:21+00:00 2026-05-17T19:20:21+00:00

I really can’t get this working so i’m hoping someone here can help :)

  • 0

I really can’t get this working so i’m hoping someone here can help 🙂

here is my castle.config:

<castle>
  <facilities>
    <facility id="nhibernatefaciltity"
              isWeb="true"
              type="Castle.Facilities.NHibernateIntegration.NHibernateFacility,  Castle.Facilities.NHibernateIntegration">
      <factory id="sessionFactory1">
        <settings>
          <item key="show_sql">true</item>
          <item key="connection.provider">NHibernate.Connection.DriverConnectionProvider</item>
          <item key="connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
          <item key="connection.connection_string">Data Source=.;Initial Catalog=xxx;User Id=xxx;Password=xxx;Pooling=False</item>
          <item key="dialect">NHibernate.Dialect.MsSql2005Dialect</item>
          <item key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</item>
        </settings>
        <assemblies>
          <assembly>Namespace.Model</assembly>
        </assemblies>
      </factory>
    </facility>
  </facilities>
</castle>

Here is the container set up in the global.asax:

Container = new WindsorContainer(new XmlInterpreter(new ConfigResource()))
            .AddFacility<WcfFacility>(f => f.Services.AspNetCompatibility =
                AspNetCompatibilityRequirementsMode.Required)

            .Register(
                Component.For<IServiceBehavior>().Instance(metadata),
                Component.For<IServiceBehavior>().Instance(debug),
                Component
                    .For<IAppServices>()
                    .ImplementedBy<AppServices>()
                    .Named("Namespace.WebServices.AppServices")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel().Hosted()
                        .AddEndpoints(
                            WcfEndpoint.BoundTo(new BasicHttpBinding()),
                            WcfEndpoint.BoundTo(new WSHttpBinding(SecurityMode.None)).At("ws")
                            ))

                );
var cfgs = Container.ResolveAll<NHibernate.Cfg.Configuration>();
foreach (var cfg in cfgs)
{
    cfg.EventListeners.SaveEventListeners =
        new ISaveOrUpdateEventListener[] { new CustomSaveEventListener() };
}

Probably more info than needed but i want to be complete here.

Here is my CustomSaveEventListener:

public class CustomSaveEventListener : DefaultSaveEventListener
{
    protected override object PerformSaveOrUpdate(SaveOrUpdateEvent evt)
    {
        IHaveAuditInformation entity = evt.Entity as IHaveAuditInformation;
        if (entity != null)
            ProcessEntityBeforeInsert(entity);

        return base.PerformSaveOrUpdate(evt);
    }

    internal virtual void ProcessEntityBeforeInsert(IHaveAuditInformation entity)
    {
        entity.DateAdded = DateTime.Now;
        entity.DateUpdated = DateTime.Now;
    }
}

Here is an example .hbm:

 <?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="GlastoStar.Model" namespace="GlastoStar.Model">
  <class name="User" table="AppUser">
    <id name="Id" column="Id" type="Int64">
      <generator class="hilo"/>
    </id>
    <property name="FirstName"></property>
    <property name="LastName"></property>
    <property name="Password"></property>
    <property name="UserName"></property>
    <property name="Email"></property>
    <property name="DateAdded"></property>
    <property name="DateUpdated"></property>
    <property name="Deleted"></property>
  </class>
</hibernate-mapping>

Here is an example entity:

public class User : IHaveAuditInformation
{
    public virtual Int64 Id { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
    public virtual string Password { get; set; }
    public virtual string UserName { get; set; }
    public virtual string Email { get; set; }
    public virtual DateTime DateAdded { get; set; }
    public virtual DateTime DateUpdated { get; set; }
    public virtual bool Deleted { get; set; }
}

AFAIK – I have done everything but there a skant resources explaining how to do this.

It’s bugging the hell out of me.

w://

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:20:21+00:00Added an answer on May 17, 2026 at 7:20 pm

    using the fluent config seemed to fix this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that adds elements to an AutoCad drawing. I noticed that
I am trying to understand the practical difference during the execution of a program
There doesn't seem to be any tried and true set of best practices to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.