I could elaborate a little.
Fragment of the XML:
Code:
<Identificacion>
<Tipo_Personalidad>1</Tipo_Personalidad>
<Nombre>NOMBRE FUNCIONARIO</Nombre>
<Apellidos>APELLIDOS FUNCIONARIO</Apellidos>
<Identificador_Administrativo>
<Tipo>3</Tipo>
<Numero_Documento>99999999L</Numero_Documento>
</Identificador_Administrativo>
</Identificacion>
And my code
Code:
Dim tramite As New Tramites
tramite.LoadByPrimaryKey(1)
Dim adminXML As XDocument = XDocument.Load("C:\test\propiedad.xml")
Dim ident = From id In adminXML...<Identificacion> _
Select New Funcionario With {.Nombre = id...<Nombre>.Value, _
.Apellidos = id...<Apellidos>.Value, _
.Nif = id...<Numero_Documento>.Value}
For Each Item As Funcionario In ident
Dim funcion As Funcionario = tramite.FuncionarioCollectionByTramitesId.AddNew 'This works, but it's not very elegant
funcion.Apellidos = Item.Apellidos
funcion.Nif = Item.Nif
funcion.Nombre = Item.Nombre
'...
'and so on... More than 100 fields in real life
'This (what I want) does not work
funcion = Item 'The ES object 'funcion' is filled with the values from
' 'Item' but only writes NULLs to the database.
Next
tramite.Save()
If I print the contents of the 'funcion' instance, the object is filled with the correct data in both cases, but if I use "funcion=item" the save just inserts the ID, FK ID and nulls.
I am lost.....