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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T10:58:55+00:00 2026-05-28T10:58:55+00:00

In my ASP.NET MVC project, my actions typically call a Service layer to get

  • 0

In my ASP.NET MVC project, my actions typically call a Service layer to get data. I use the same dozen or so POCOs for all my models. I also plan on using the Service layer in console applications and maybe expose a web api at some point.

To make my database operations more efficient, my service layer only hydrates the properties in the model that are relevant to the particular method (which at this point is mostly driven by the needs of my controller actions).

So for example I might have a class Order with properties Id, Name, Description, Amount, Items. For a given service call I might only need to populate Id, Name, Items. A consumer of that service won’t necessarily know that Amount is 0 only because it didn’t populate the property.

Similarly, the consumer won’t know whether Items is empty b/c there actually aren’t any items, or whether this particular service method just doesn’t populate that property.

And for a third example, say one of my views displays an ItemCount. I don’t want to fully populate my Items collection, I just need an additional property on my “model”. I don’t want to add this property to my POCO that other service methods will be using because it’s not going to be populated anywhere else.

So the natural solution is to make a POCO designed specifically for that method with only those 3 properties. That way the consumer can know that all properties will be populated with its real values. The downside to this is that I’ll end writing tons of similarly shaped models.

Any advice on which method works best?

  • 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-28T10:58:55+00:00Added an answer on May 28, 2026 at 10:58 am

    You could use Nullable Types to indicate the missing properties with a null.

    For example:

    class Order {
        public int Id {get;set;}
        public string Name {get;set;}
        public string Description {get;set;}
        public decimal? Amount {get;set;}
        public List<Item> Items {get;set;}
    }
    

    And then if Items == null, it wasn’t set. If it’s an empty new List<Item>(), it’s set but empty. Same for Amount. If Amount.HasValue == false, it wasn’t set. If Amount.Value is 0.0d, it’s set and the item is free.

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

Sidebar

Related Questions

I have an ASP.NET MVC project with xVal and data annotations and I need
In my ASP.net mvc app I am using a Service Layer and Repositories to
I'm enjoying Asp.Net MVC and am looking to use it in an upcoming project.
I have an ASP.NET MVC 4 project in which I use an HTML input
I've got a very basic ASP.Net MVC project where I'd like to use a
Does anyone have experience using ASP.NET MVC project as a Web Service? i.e. using
I just created a ASP.NET MVC project and was able to build and browse
In our ASP.NET MVC project we have a Strings.resx file and the accompanying autogenerated
I have a new asp.net mvc project and i am trying to figure out
I'm starting an ASP.NET MVC project using SubSonic 3 ActiveRecord. I added a table

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.