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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:14:08+00:00 2026-06-16T03:14:08+00:00

So I am doing a simple project management system and have run into a

  • 0

So I am doing a simple project management system and have run into a LINQ quandry. This is probably common. Project tasks are based on templates (which share a table with tasks in the database). A project task has several fields that are inherited by default from the task template unless they have a value. For example, a ProjectTask record with a UnitPrice of 0 will look to the ProjectTask template record to get the actual price.

How do I implement this with LINQ? I thought about doing an ObjectDataSource, but that gets away from how I am doing all the other data (in LINQ). I tried creating a derived class with code like the below, but it doesn’t show up in LinqDataSource, even when I set up inheritance in the ORM designer.

I’ve done some googling but can’t seem to find a good model. Any thoughts? Thanks as always.

public class ProjectTaskWithInheritance : ProjectTask
{
    public new decimal UnitPrice
    {
        get
        {
            if (IsServiceOverride)
                if (base.UnitPrice != 0)
                    return base.UnitPrice;

            return base.TaskTemplateRecord.UnitPrice;
        }
        set { base.UnitPrice = value; }
    }
}
  • 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-16T03:14:09+00:00Added an answer on June 16, 2026 at 3:14 am

    You are mixing up the levels of inheritance: your system models things that inherit from each other (i.e. a project task inherits a UnitPrice from a project task template); at the same time, you are trying to model it with inheritance in your .NET program. These are two different inheritances: one is in your data layer, while the other one is in your code layer.

    I would suggest modeling the inheritance in the data layer with containment in the code layer, rather than using an inheritance. Each ProjectTask can have an optional instance of ProjectTask that serves as a task template; when a property is not found in the task itself, try looking it up in the template object. Make properties nullable to allow for situations when a property is not set in either the object or its template.

    class ProjectTask {
        private ProjectTask Template {get;set;}
        private decimal? unitPriceOverride;
        public decimal UnitPrice {
             get {
                 return unitPriceOverride ?? (Template != null ? Template.UnitPrice : null);
             }
             set {
                 unitPriceOverride = value;
             }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple class project where i'm doing some form validation. We have
hello i m doing a very simple Asp.net application project namespace WebApplication1 { public
A simple description of our architecture for the school project we are doing: -we
I a doing a weird project, and looking to convert some short, simple datagrams
I've been doing simple multi-threading in VB.NET for a while, and have just gotten
I have a WCF service hosted in IIS6. It is doing simple WebRequest. When
I already have some simple project with one migration script: # --- !Ups create
I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a
I just had a hell of a project doing simple operations on C++, then
I'm doing a simple project to manage data for a tabletop game, but I'm

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.