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

  • Home
  • SEARCH
  • 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 708429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:23:24+00:00 2026-05-14T04:23:24+00:00

When I do a save of an entity with assigned id I get a

  • 0

When I do a save of an entity with assigned id I get a

SharpArch.Core.PreconditionException:
For better clarity and reliability,
Entities with an assigned Id must call
Save or Update

My class is

public class CompanyUserRepository :
RepositoryWithTypedId<CompanyUser, string>, ICompanyUserRepository
{
   public override CompanyUser SaveOrUpdate(CompanyUser entity)
   {
     var user = base.SaveOrUpdate(entity);
     //Do some stuff
     return user;
   }
}

How do I go about saving this entity?

RepositoryWithTypedId does not expose a Save method

Related question. This tells you the reason, but I haven’t found out the Sharp Architecture way to do a Save.

  • 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-14T04:23:25+00:00Added an answer on May 14, 2026 at 4:23 am

    Digging through the NorthWind example in the S#arp repo, I found out the answer.

    The Repository class should derive from NHibernateRepositoryWithTypedId

    e.g.

    public class CustomerRepository : NHibernateRepositoryWithTypedId<Customer, string>, ICustomerRepository
    {
        public List<Customer> FindByCountry(string countryName) {
            ICriteria criteria = Session.CreateCriteria(typeof(Customer))
                .Add(Expression.Eq("Country", countryName));
    
    
            return criteria.List<Customer>() as List<Customer>;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I save an entity using a Hibernate session, and then probe to get
I have two generic save methods in a repository class: public void Save<T>(T entity)
I am using NHibernate and need to update/add an entity class(a) that can reference
When I try to save an entity I get an error: Object reference not
I am using Google App Engine with Google's JDO implementation to save an entity
Let's say I create a new Entity and Save it as follows: UserReport report
I want to save one of my entity objects into the session, but as
Save one image path in the database... and whenever a call is made to
I have three methods: public void Save<T>(T entity) { using (new Transaction()) { Session.Save(entity);
Take a look at the following classes (UNIdirectional @OneToMany) @Entity public class Team {

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.