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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:09:03+00:00 2026-06-18T15:09:03+00:00

I have a Class (Entity we call them) Named Person which is mapped to

  • 0

I have a Class (Entity we call them) Named Person which is mapped to a database Table (Person table). The records of this table may contain null values in all fields but one, the PK.

This is in brief how we define our Person entity:

...
private System.DateTime _BirthDate;

[DisplayName("Birth Date")]
[Category("Column")]
public System.DateTime BirthDate
{
    get
    {
        try { return _BirthDate; }
        catch (System.Exception err) 
        { throw new Exception("Error getting BirthDate", err); }
    }
    set
    {
        try { _BirthDate = value; }
        catch (System.Exception err)
        { throw new Exception("Error setting BirthDate", err); }
    }
}
...

the problem is that when I get the list of persons

var dsPersons = DataHelper.personTabelAdapter.GetFilteredPersons(nationalNo, name);

those fields which were null in db, are having exceptions so I can’t compare them to null or even DBNull.Value, look at the following image of my code in debug

enter image description here

I want to check their being null, so that I can decide to fill my new objects fields or not to fill them.

here’s the details of the exception I get

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.StrongTypingException: The value for column 'BirthDateFa' in table 'Person' is DBNull. ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

   at EcomService.Data.EcomDS.PersonRow.get_BirthDateFa() in c:\Projects\Project\EcomForms\EcomService\EcomService\Data\EcomDS.Designer.cs:line 30607

   --- End of inner exception stack trace ---

   at EcomService.Data.EcomDS.PersonRow.get_BirthDateFa() in c:\Projects\Project\EcomForms\EcomService\EcomService\Data\EcomDS.Designer.cs:line 30610

   at EcomService.Classes.Entities.Person.GetFilteredPersons(String nationalNo, String name) in c:\Projects\Project\EcomForms\EcomService\EcomService\Classes\Entities\Person.cs:line 898

   at EcomService.EService.GetFilteredPersons(String nationalNo, String name) in c:\Projects\Project\EcomForms\EcomService\EcomService\EService.asmx.cs:line 172

   --- End of inner exception stack trace ---

this is my web method

[WebMethod]
public List<Person> GetFilteredPersons(string nationalNo, string name)
{
    return Person.GetFilteredPersons(nationalNo, name);
}

that calls this method

static public List<Person> GetFilteredPersons(string nationalNo, string name)
{
    List<Person> persons = new List<Person>();
    var dsPersons = DataHelper.personTabelAdapter.GetFilteredPersons(nationalNo, name);
    foreach (var dsPerson in dsPersons)
    {
        Person person = new Person();
        person.BirthDateFa = dsPerson.BirthDateFa;
        //I don't know how to deal with the exceptions here
        .... //other fields
        persons.Add(person);
    }
    return persons;
}

I am really stuck in this piece. Your answers will be kindly welcome.

  • 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-18T15:09:05+00:00Added an answer on June 18, 2026 at 3:09 pm

    The exception comes because you are using a strongly typed DataSet. StrongTypingException documentation says it:

    The exception that is thrown by a strongly typed DataSet when the user accesses a DBNull value.

    Please read this article,
    http://msdn.microsoft.com/en-us/magazine/cc163877.aspx

    Example :

    object.Is<ColumnName>Null() //which returns true or false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class hierarchy like this: @Entity @Table (name=call_distribution_policies) @Inheritance (strategy=InheritanceType.JOINED) public class
I have strongly typed entity class, which is used for Linq-To-Sql: [Table(Name = _Reference2)]
I used JPA and mysql. Each table have entity class.I have four tables. Table1
I have an Entity class, which contains 3 pointers: m_rigidBody, m_entity, and m_parent. Somewhere
I have the following entity class : @Entity @Table(name = THE_TREE, catalog = ,
I have two tables, both named Language in two different schemas, lets call them
I have an entity named Tour which can have many Agents . I am
I have an Entity class that exposes a read-only Id property. This property gets
I have three classes (House, Room, Address) which are persistent (Mapped with JPA/Hibernate) @Entity
I have class with back reference: public class Employee : Entity { private string

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.