Entity Framework and DB fields with null value RRS feed

  • Question

  • Hello,


    I just create a Web Service in C# which return an array of contact (id, last_name, first_name, phone...) which come from a MySQL DB and I get it through Entity Framework.

    When I get the xml file generate by my Web Service, I can see that the columns whose have a null value (i.e. name=null) are not write to the xml :

    record 1:

      <date1 xsi:nil="true"/>

    record 2:

      <addresses_id xsi:nil="true"/>
      <date1 xsi:nil="true"/>

    we can sse that "position" column are not insert in the first record because is value is null in the database.

    Is there a way to force Entity Framework to write it everytime else if it is null ?


    Very simple code of my Web Service:

      public contact[] GetContacts()
        return db.contact.ToArray();

    many thanks in advance.




    Thursday, October 27, 2011 8:58 AM