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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:16:00+00:00 2026-06-05T08:16:00+00:00

Using POCO and Fluent NHibernate, I would like to have the ability to take

  • 0

Using POCO and Fluent NHibernate, I would like to have the ability to take an object like User and be able to give it various properties. I would like these objects to be able to focus on their properties, not common properties. Currently, I have an AuditableEntity that I can derive from to give my entity the ability to have Audited properties like CreatedDateTime and ModifiedDateTime, but I would also like to have the ability to take out the need to implement my Id for every object, Id’s should be able to be part of some other base object, so I could say this object has a Guid Id and this one has an int id and this one has no Id. Currently, my User object looks like this:

User.cs

namespace ZeroBase.Domain.Entities
{
public class User : AuditableEntity<User>
{
    public virtual Guid Id { get; set; }
    public virtual string Username { get; set; }
    public virtual string Password { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
    public virtual string EmailAddress { get; set; }
    public virtual IEnumerable<Comment> Comments { get; set; }
}
}

and my UserMap looks like this:

UserMap.cs

namespace ZeroBase.Infrastructure.Data
{
public class UserMap : AuditMap<User>
{
    public UserMap()
    {
        Id(x => x.Id)
            .Column("Id")
            .GeneratedBy.Guid();
        Map(x => x.Username);
        Map(x => x.Password);
        Map(x => x.FirstName);
        Map(x => x.LastName);
        Map(x => x.EmailAddress);
        HasMany(x => x.Comments);
        Table("Users");
    }
}
}

Is there anyway to handle the Id creation in some sort of a generic base class and still have a separate class that objects can inherit from to become auditable?

  • 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-06-05T08:16:01+00:00Added an answer on June 5, 2026 at 8:16 am

    Are you using AuditableEntity for classes without an id? Entity implies that the class has an identity. Based on this, I would say that you can add a Id property to AuditableEntity.

    If you are using it for classes without an identity, like value objects, I would create another base class. Would something like this make sense?

    class Entity {
        Guid Id { get; set; } 
    
        public Entity() {
            Id = Guid.NewGuid();
        }
    }
    
    interface IAuditable<T> {
        DateTime CreatedAt {get; set; }
        // ...
    }
    
    class AuditableEntity<T> : Entity, IAuditable<T> {
        DateTime CreatedAt { get; set; }
    }
    
    class AuditableValueObject<T> : IAuditable<T> {
        DateTime CreatedAt { get; set; }
    }
    
    // Class that has both an identity and is auditable
    class User : AuditableEntity<User> {
        // ..
    }
    
    // Class without an identity but auditable
    class Money : AuditableValueObject<Money> {
        // ..
    }
    
    // Class with an identity but not auditable
    class Customer : Entity {
        // ..
    }
    

    Note: Entity, value objects etc. are terms of Domain Driven Design (DDD).

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

Sidebar

Related Questions

I define my data model using Fluent nHibernate POCO classes + mappings. I'm also
I'm using POCO proxies and I'd like to get the type of a object.
I am using poco objects I wrote with entity framework. I would like to
I'm trying to take a POCO object and update it with Linq2SQL using an
I have a simple Poco-Model using abstract classes, and it seems not to work
I am using NHibernate 3.1 and Fluent NHibernate as ORM in my project. I
In delving into Fluent nHibernate, I discovered a potential breaker for using it... Given
I started using POCO and have looked over the documentation of threads. From this,
I have generated my POCO entities using POCO Generator, I have more than 150+
I have an assembly generated using POCO template using Entity Framework (e.g. Company.Models.dll).Besides generated

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.