Well this sounds like a general issue with objects. If you want to perform
an operation on an object, you should either check if the object is null
before or perform an operation which gives a meaningful result for you in
the case the object is null.

BTW, if your row coming from the db maps 1-1 to a class, you could exploit
the Row.ToObject method.
On Thu, Jun 3, 2010 at 16:19, jweizman <[email protected]> wrote:

> In the following code, when i want to write the result i face the Null
> issue. If the fiels read is null then it throws an exception.
> The way i deal with it is by placing a if test.... Is there a better
> way ?
> Thanks
>
> foreach (Row  row in rows)
>           {
>               IFormatProvider culture = new CultureInfo("fr-FR",
> true);
>               .Entities.Contact d = new Entities.Contact );
>
>
>                  d.id = Guid.Parse(row["id_c"].ToString());
>                  d.salutation = row["salutation"].ToString();
>                  d.first_name=   row["first_name"].ToString();
>                  d.last_name= row["last_name"].ToString();
>                  if (row["birthdate"] != null)
>                      d.birthdate =
> DateTime.Parse(row["birthdate"].ToString(), culture,
> DateTimeStyles.None);
>
>                  if (row["phone_home"] != null)
>                        d.phone_home=  row["phone_home"].ToString();
>                  if (row["phone_work"] != null)
>                        d.phone_work = row["phone_work"].ToString();
>
>                  dataAccess.Save(d);
>           }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Rhino Tools Dev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rhino-tools-dev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhino-tools-dev?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en.

Reply via email to