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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:51:10+00:00 2026-05-14T19:51:10+00:00

i have my auto-generated linq to sql classes, and i extend this class using

  • 0

i have my auto-generated linq to sql classes, and i extend this class using partial classing (instead of using inheritance), and i have properties that that i’ve put in later which are not part of the database model and should not be. these are things like “FinalPrice” and “DisplayFinalPrice” – in the dbase, there is only RetailPrice and WholesalePrice so FinalPrice etc are more like extensions of the dbase fields.

when i submit the form with nothing filled in, “FinalPrice” gets called (the ‘get’ of the property) even tho i never ask for it to be, and even tho it is not needed. this happens before validation, so i don’t even get the validation errors i would get.

i’ve tried using and on the FinalPrice and FinalPriceDisplay properties – no go! why does this happen and how can i stop it from happening? is the modelstate just trying to validate everything so therefore it calls every item no matter what?

for those interested, here is all the code…

Partial Public Class tProduct
‘Inherits tProduct
Private Const CommissionMultiplier As Decimal = CDec(1.18)
Private _FinalPrice As Decimal?
Private _DisplayFinalPrice As String
Private _DisplayNormalPrice As String

Public Property CategoryComplete As Short

<ScaffoldColumn(False)>
Public ReadOnly Property FinalPrice As Decimal
    Get
        'If RetailPrice IsNot Nothing OrElse WholesalePrice IsNot Nothing Then
        If _FinalPrice Is Nothing Then
            If RetailPrice IsNot Nothing Then
                _FinalPrice = RetailPrice
            Else
                _FinalPrice = WholesalePrice * CommissionMultiplier ' TODO: this should be rounded to the nearest 5th cent so prices don't look weird.
            End If

            Dim NormalPart = Decimal.Floor(_FinalPrice.Value)
            Dim DecimalPart = _FinalPrice.Value - NormalPart

            If DecimalPart = 0 OrElse DecimalPart = 0.5 Then
                Return _FinalPrice

            ElseIf DecimalPart > 0 AndAlso DecimalPart < 0.5 Then
                DecimalPart = 0.5   ' always rounded up to the nearest 50 cents.
            ElseIf DecimalPart > 0.5 AndAlso DecimalPart < 1 Then
                ' Only in this case round down if its about to be rounded up to a valeu like 20, 30 or 50 etc as we want most prices to end in 9.
                If NormalPart.ToString.LastChr.ToInt = 9 Then
                    DecimalPart = 0.5
                Else
                    DecimalPart = 1
                End If
            End If

            _FinalPrice = NormalPart + DecimalPart
        End If

        Return _FinalPrice
        'End If

    End Get
End Property

<ScaffoldColumn(False)>
Public ReadOnly Property DisplayFinalPrice As String
    Get

        If _DisplayFinalPrice.IsNullOrEmpty Then
            _DisplayFinalPrice = FormatCurrency(FinalPrice, 2, TriState.True)
        End If

        Return _DisplayFinalPrice
    End Get
End Property

Public ReadOnly Property DisplayNormalPrice As String
    Get
        If _DisplayNormalPrice.IsNullOrEmpty Then
            _DisplayNormalPrice = FormatCurrency(NormalPrice, 2, TriState.True)
        End If

        Return _DisplayNormalPrice

    End Get
End Property

Public ReadOnly Property DivID As String
    Get
            Return "pdiv" & ProductID
        End Get
    End Property


End Class

more…

i get busted here, with a null reference exception telling me it should contain a value…

                Dim NormalPart = Decimal.Floor(_FinalPrice.Value)

i can get rid of the problem, by just wrapping the commented out if statement in the code, but this shouldnt be called to begin with, and that’s the issue im having.

  • 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-14T19:51:10+00:00Added an answer on May 14, 2026 at 7:51 pm

    It looks like you are experiencing this problem (may be same issue?):

    Why does ASP.NET MVC care about my read only properties during databinding?

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

Sidebar

Ask A Question

Stats

  • Questions 409k
  • Answers 409k
  • 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 To my knowledge, there is nothing in the UIWebView API… May 15, 2026 at 7:08 am
  • Editorial Team
    Editorial Team added an answer This solution would also be triggered if the margins were… May 15, 2026 at 7:08 am
  • Editorial Team
    Editorial Team added an answer You have some unwanted semicolons: clickerButton.setOnClickListener(new View.OnClickListener()); public void onClick();… May 15, 2026 at 7:08 am

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.