lankapala
asked on
C# WebAPI Array issue
Hi, I'm trying send to using SOAP to data,but it's keep sending the same value. I created array ,but didn't work
My code
Web services Code
Any idea much appreciated. Just want to know why is keep recording last number in the all the array.
For example
if in the order having ID 500,800,900.
It will keep saving in the array 900 for all the array[0],array[1] and array[2]
MAny Thanks
My code
OMS.OfferOrdered oOfferOrdered = new OMS.OfferOrdered();
newOrders.Offers = new OMS.OfferOrdered[TotalNumberLine];
OMS.OfferIDHeader oOfferIDHeader = new OMS.OfferIDHeader();
OMS.OfferID oOfferID = new OMS.OfferID();
while (reader.Read())
{
newOrders.Offers[i].Offer.Header.ID = reader["OfferHeaderID"].ToString();
}
Web services Code
public partial class OfferOrdered : PMObject {
private OfferID offerField;
}
public partial class OfferOrdered : PMObject {
[System.Xml.Serialization.XmlArrayAttribute(Order=9)]
public OfferOrdered[] Offers {
get {
return this.offersField;
}
set {
this.offersField = value;
this.RaisePropertyChanged("Offers");
}
}
}
public partial class OfferIDHeader : PMObject {
[System.Xml.Serialization.XmlElementAttribute(Order=1)]
public string ID {
get {
return this.idField;
}
set {
this.idField = value;
this.RaisePropertyChanged("ID");
}
}
}
public OfferIDHeader Header {
get {
return this.headerField;
}
set {
this.headerField = value;
this.RaisePropertyChanged("Header");
}
}
}
Any idea much appreciated. Just want to know why is keep recording last number in the all the array.
For example
if in the order having ID 500,800,900.
It will keep saving in the array 900 for all the array[0],array[1] and array[2]
MAny Thanks
ASKER
ok, Any idea what is the issue
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As written, that wasn’t the problem. In your OP all you ever requested from the reader was the OfferHeaderID value.
ASKER
@Kelvin McDaniel:
if you know the answer , why you didn't help me.now to late.Anyway i found the answer.
I'll appreciate,if you show me how to do that or where is mistake.rather than commenting after that .
Many thanks
if you know the answer , why you didn't help me.now to late.Anyway i found the answer.
I'll appreciate,if you show me how to do that or where is mistake.rather than commenting after that .
Many thanks
A couple of things:
1). I “didn’t help” you because I literally saw this question for the first time no more than 15 minutes ago. Regardless, my response has the help I would give — just not in code.
2). Experts don’t get paid for this; I’m literally in the middle of my workday morning “ritual” and I’m giving my time away for free... so be nice. :)
In your code you have the following:
This line dictates what you are modifying on an object at a specified index (i) of that array:
Your code does not show how you are incrementing i but that’s less of an issue because at least it is certainly a variable and in your OP you stated that your array is larger than one item. From what you’ve given us, nothing changes what you’re looking for from the reader; only the single value of OfferHeaderID is ever retrieved. You’ll need to use a variable instead of ”OfferHeaderID” if you want to get something else out of the reader.
Good Luck!
1). I “didn’t help” you because I literally saw this question for the first time no more than 15 minutes ago. Regardless, my response has the help I would give — just not in code.
2). Experts don’t get paid for this; I’m literally in the middle of my workday morning “ritual” and I’m giving my time away for free... so be nice. :)
In your code you have the following:
while (reader.Read())
{
newOrders.Offers[i].Offer.Header.ID = reader["OfferHeaderID"].ToString();
}
This line dictates what you are modifying on an object at a specified index (i) of that array:
newOrders.Offers[i].Offer.Header.ID = reader["OfferHeaderID"].ToString();
Your code does not show how you are incrementing i but that’s less of an issue because at least it is certainly a variable and in your OP you stated that your array is larger than one item. From what you’ve given us, nothing changes what you’re looking for from the reader; only the single value of OfferHeaderID is ever retrieved. You’ll need to use a variable instead of ”OfferHeaderID” if you want to get something else out of the reader.
Good Luck!
ASKER
Thank you very much for reply
Sorry my mistake,not putting whole code.
Yes, there is i increment.
No it's not larger than.
Sorry my mistake,not putting whole code.
Yes, there is i increment.
No it's not larger than.
ASKER
I found the issue