Je suis un F # n00b total, donc j'espère vous donner assez d'informations. J'ai créé une classe appelée enregistrement. Je crée plusieurs instances de cette classe avec des données de notre base de données. J'ajoute ensuite chaque enregistrement à une liste d'enregistrements. Je veux faire un document XML avec ces enregistrements.Sérialisation XML avec F #
//this is the record data type i created. I also created a sender and recipient data
//type but those are probably not neccessary to understand the issue
type record(id:int, sender:sender, ?recipients: recipient list) =
let mutable id: int = id
let mutable typ = "Message"
let mutable creation = creation()
let mutable sender = sender
let mutable recipients = recipients
[<XmlIgnore()>]
[<XmlArrayAttribute("recipients")>]
[<XmlArrayItem(typeof<recipient>, ElementName = "recipient")>]
member this.Recipients with get() = recipients and set v = recipients <- v
public new() =
record(12180, sender(12180,"Joe","Plumber","[email protected]"), list.Empty)
[<XmlElement("id")>]
member this.Id with get() = id and set v = id <- v
[<XmlElement("creation")>]
member this.Creation with get() = creation and set v = creation <- v
[<XmlElement("sender")>]
member this.Sender with get() = sender and set v = sender <- v
//i later call this:
let xmlSerializer = XmlSerializer(typeof<record list>)
Je puis reçois ce message d'erreur lors de l'exécution:
Il y avait un type qui reflète l'erreur 'Microsoft.FSharp.Collections.FSharpList`1 [XXXX.Compliance.YYYYY.record]. // x et y sont utilisés pour protéger les innocents.
Je pense que vous avez raison. J'ai tout changé en tableaux au lieu de listes. Il semble avoir fait l'affaire. – Ramy