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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:21:54+00:00 2026-05-23T22:21:54+00:00

I am using POCOs (no proxies) with EF4. In the database, I have this

  • 0

I am using POCOs (no proxies) with EF4.

In the database, I have this nullable decimal column:

<Property Name="AMOUNT" Type="decimal" Precision="12" Scale="2" />

On my POCO, I have this non-nullable value property:

public decimal Amount { get; set; }

If the value in the database is null, I want the property to be set to 0. How can I achieve this? I would prefer not to have a Nullable property here, otherwise I have to pollute my business logic with GetValueOrDefault() code.

[This question seemed like what I was asking, but I’m not sure it was really answered.]

  • 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-23T22:21:55+00:00Added an answer on May 23, 2026 at 10:21 pm

    Unfortunately you must use nullable decimal in your POCO because EF doesn’t provide any simple type mapping / type converters where you could place your transformation logic. Types must be same to make it work.

    In case of EDMX there is one possible ugly workaround. You can map your column to non public property and expose another public property which will be not mapped (in your partial part of POCO class) and you will have your conversion logic in its getter and setter. Here is described how you can change visibility of property.

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

Sidebar

Related Questions

I have been using a custom type for Money with my POCOs and tries
I'm using ModelBuilder to map an existing database to POCOs. I have courses, students,
I'm using Entity Framework Code-First with POCOs for my database interaction. I have a
I am using Entity Framework 4.1 with POCOs and DbContext, no proxies no lazy
I'm using a SQLdatareader to build POCOs from a database. The code works except
I'm using EF4 POCOs and UnitOfWork/repository patterns with MVC 3. I'm trying to understand
I'm using Entity Framework 4.1 (database first, e.g old school), and i'm using POCOs
I have an MVC3 project that is using an EF4 project as its Domain.
Are there any disadvantages for using the same POCOs (in EF4 & WCF) across
I am using ASP.NET MVC2 with EF4. I need to create POCOs for two

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.