i'm currently working a case where i have to import a lot of data from the database and output it as an xml that matches to an xsd schema. i used xsd.exe to generate the c# class for a particular schema.
my question is, how do i use this class to be populated w/ data from the database?
my class looks like this: `
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "TTC_Queue")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "MT_Queue", IsNullable = false)]
public partial class STAGING_Low
{
private object[] itemsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("TTC_Queue", typeof(TTC_Queue))]
[System.Xml.Serialization.XmlElementAttribute("ROW_COUNTS", typeof(ROW_COUNTS))]
public object[] Items
{
get
{
return this.itemsField;
}
set
{
this.itemsField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "TTC_Queue")]
public partial class TTC_Queue
{
private System.Data.SqlTypes.SqlDecimal reportingUnitCodeField;
private bool reportingUnitCodeFieldSpecified;
private System.Data.SqlTypes.SqlString preparerNField;
//more fields
`
i will have multiple elements of the "ttc_queue" to populate in this. i already have populated an object[] of ttc_queue to be used in this.
how do i set this array to the "item fields" and then also deserialize this?
i currently have:
STAGING_low low = new STAGING_Low();
low.Items = new TTC_Queue[1];
low.Items.SetValue(myObject[],0);
where i'm setting the value i get an error:
An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll
Additional information: Object cannot be stored in an array of this type.
i'm not sure what i'm missing.
thanks for the assistance.