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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:02:19+00:00 2026-05-17T07:02:19+00:00

I have alluded to this issue in my other question , but i think

  • 0

I have alluded to this issue in my other question, but i think it’s worthwhile breaking it out into its own question, as it’s not really dependant on the other scenarios i mentioned.

Anyways – onto the Q, don’t know if this is possible. Looking for a solution/workaround.

I have a Class Library, with nothing but POCO’s:

MyCompany.MyProject.Domain.POCO

This assembly has a POCO like this:

public class Post
{
   public int PostId { get; set; }
   public int Name { get; set; }
      ...
}

Now, i have another Class Library, which is my DAL/Repository, and uses Entity Framework 4.0 for the persistence:

MyCompany.MyProject.Repositories

This assembly has a reference to the POCO project, as it needs to be perform CRUD operations on the POCO’s (grab DB objects, project into POCO’s, return, as well as modify POCO’s).

Now, i also have a Web Application, which has a reference to both the POCO and Repository assembly.

If i do this:

somePOCO.PostId = 10;

I get a SQLException, as PostId is an IDENTITY field in the database, and hence should not be explicity set.

Is there a way i can hide the setter for these special properties, so that only the repository has access to the setter?

I can’t think of a way to do it with regular accessibility modifiers (as none of them suit the scenario), can you guys think of a workaround?

  • 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-17T07:02:21+00:00Added an answer on May 17, 2026 at 7:02 am

    you could make the setter internal, and make the internals visible to the repository assembly

    [assembly: InternalsVisibleTo("MyLibrary.Repositories")]
    public class Post
    {
       public int PostId { get; internal set; }
       public int Name { get; internal set; }
          ...
    }
    

    This means that everything can ‘get’ those properties, but only this assembly, and the assembly containing the repository, can ‘set’

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

Sidebar

Related Questions

I've alluded to this project before, in this question, but the scope of redesign
This is probably a newbie face-palm question, but I can't figure this out. I'm
have Googled the cr*p out of this one so apologies if the answer is
So, I have this true/false question in my computer science class (we're using Java):
Have converted devise new session from erb to Haml but doens't work, this is
As described here http://www.ddj.com/cpp/184401688 I do not have time to write this from scratch.
I have a table like this: create table SomeTable ( tableKey int identity(1,1) not
I have a question that must surely seem very trivial, but the answer has
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:

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.