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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:35:51+00:00 2026-05-13T15:35:51+00:00

Consider, for example: public interface IStaff { FullName name { get; set; } EMailAddress

  • 0

Consider, for example:

public interface IStaff
{
    FullName name { get; set; }
    EMailAddress email_address { get; set; }
    SocialInsuranceId ssn { get; set; }
    PositiveInt age { get; set; }
    Address home_address { get; set; }
}

For some users, the viewmodel will only require name and email_address.
Others may have a viewmodel that includes those properties plus ssn, age and home_address. Let’s say there is also a statistician, whose view gets age and home_address.

Now, I could split this out into IStaffBasic, IStaffDetails, and IStaffStats with interface inheritance to limit the API in a given viewmodel to the appropriate properties.

However, when this entity is retrieved from the data service across the wire, it will still include the additional details, which must not occur.

So, would it be better to
(A) create wholly different entity types for each of these versions, somewhat polluting the service layer API with many additional near-duplicate query operations for each type, or
(B) always return a Staff entity, but (1) return them from the service with excluded properties set to null based on the authorization check at the service and (2) use limited interfaces within the viewmodels as described above, or
(C) use the very elegant pattern or solution that I haven’t considered, but about which you’re going to tell me.

Option A seems cleaner at the viewmodel level, but the service API is going to be nasty. Option B seems to add complexity to entity handling on the server, but better adherence to the open-closed principle.

Thoughts?

  • 1 1 Answer
  • 1 View
  • 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-13T15:35:52+00:00Added an answer on May 13, 2026 at 3:35 pm

    Projection is the way to go – combine options A and B.

    Your ORM should only interact with a single entity type, Staff, so you only have to maintain (and extend) a single set of mappings, queries, and so forth.

    However, you’ll also create different classes suitable for each security scenario (IStaffBasic, IStaffDetails, etc.), project the Staff instances into those, and return the projected objects over the wire:

    Some ORMs support projection as a framework feature, but if need be, you can do it manually in your service layer.

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

Sidebar

Ask A Question

Stats

  • Questions 302k
  • Answers 302k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use dbcc checkident to reset the identity seed,… May 13, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer This is easy: void ProcessCommandLine(string commandLine) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(()… May 13, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer You can set label's border via its underlying CALayer property:… May 13, 2026 at 8:26 pm

Related Questions

Consider the following simple RESTEasy (JAX-RS) service: @Path(/example-service) public interface ExampleService { @Path(/ping) @GET
Consider the following example. I have an interface MyInterface, and then two abstract classes
Consider the following two Java files that contain a simplified version of my issue
I have client/server applications and a very simple protocol for communication. More precisely, it's
I understand how the new keyword can hide methods in a derived class. However,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.