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 6149599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:28:48+00:00 2026-05-23T19:28:48+00:00

Basically I have a simple base class: public abstract class BasePoco { public virtual

  • 0

Basically I have a simple base class:

public abstract class BasePoco {

    public virtual Guid Id { get; protected set; }
    public virtual DateTime Created { get; protected set; }
    public virtual DateTime LastModified { get; protected set; }
    public virtual User LastModifiedBy { get; set; }

}

With the following mapping:

<class name="BasePoco" abstract="true">
    <id name="Id">
      <generator class="guid.comb" />
    </id>
    <property name="Created" generated="insert" />
    <property name="LastModified" generated="always" />
    <many-to-one name="LastModifiedBy" />
</class>

The Created property is set via a database default value, the LastModified via a database trigger (haven’t tested it yet, but I assume this will work). But how can I set the “LastModifiedBy” in a nice clean way? Instead of setting this property in my code every time I want to update a poco, I’d like to have something like a static method NHibernate can call on every update (and of course, this method will return the currently logged on user).

Thanks in advance

  • 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-23T19:28:49+00:00Added an answer on May 23, 2026 at 7:28 pm

    You can hook to events that fire before inserts and updates in Nhibernate; you can add audit, autofill some fields, etc… This Ayende post (very recommended) also covers the basics

    I managed my createdDate/modifiedDate/createdBy fields this way, and also added audit so i could allow hard-deletions in the database while keeping information about what was deleted

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

Sidebar

Related Questions

Basically, I have a pure virtual class Base, and a concrete class Derived which
I have an abstract class BaseItem declared like this: public abstract class BaseItem {
Okay so basically : i have this simple example: main.cpp using namespace VHGO::Resource; std::list<BaseTable*>
I have a derived class that's a very thin wrapper around a base class.
I have a class that I want to use to store properties for another
I have a container class that has a generic parameter which is constrained to
Basically, I have the following scenario: ViewModel: FooViewModel : BaseViewModel , BarViewModel : BaseViewModel
Basically I want a Topic to have many Posts and Posts to have many
So I want to be able to add/remove class methods at runtime. Before you
In PHP, if you define a class, and then instantiate an object of that

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.