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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:21:27+00:00 2026-05-26T00:21:27+00:00

Hi i have a Linq to Entity Statement that returns a Zipcode. and I

  • 0

Hi i have a Linq to Entity Statement that returns a Zipcode.
and I store this return Zip code in my strongly typed Lists
In my List Zipcode Data type is int
when my Liq statement returns Zipcode there are some NULL and Empty values
and I am not able to convert these NULL and Empty values to int
how can i handle this situation.
I tried something like this

ZipCode= Convert.ToInt32(p.ZipCode ?? "0")

any help is greatly appreciated.

thanks

  • 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-26T00:21:28+00:00Added an answer on May 26, 2026 at 12:21 am

    If you are doing this in memory (after results have already been pulled from the database), and to do that in one line, you would write something like

    int zip = Convert.ToInt32(!string.IsNullOrEmpty(p.ZipCode) ? p.ZipCode : "0");
    

    If you are trying to convert the string to an integer inside query at the database, you might have to define a custom defined function that will translate a conversion to the proper cast at the database. See this related question for a possible implementation.

    However, I would encourage you not to convert a zip code to an integer. A zip is not a numeric value, despite being composed of numbers (in parts of the world). Treat it as a proper string, which it looks like you are already doing inside p (and presumably the database). The same premise applies to phone numbers, SSNs, account numbers, etc.

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

Sidebar

Related Questions

I have LINQ statement that looks like this: return ( from c in customers
I have a LINQ to ENTITY query that pulls from a table, but I
I am using Linq and the Entity Framework. I have a Page Entity, that
I have the following LINQ query that I need to translate to Entity SQL
I have a method that contains the following Linq to SQL code: public List<L2SBusinessEntities.Report.MesReport>
i have some Linq to Entity code like so: var tablearows = Context.TableB.Include(TableA).Where(c =>
I have an entity that looks like this: public partial class MemberTank { public
I have a stored procedure that returns a collection of my entity class objects.
I have a LINQ entity that I need to create a special string value
So, I am using the Linq entity framework. I have 2 entities: Content and

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.