There is a service which is migrated to WCF. The most methods have int, string, DateTime parameters and everything is working fine, but one method receives an array of custom class objects.
[DataContract]
public class Term
{
[DataMember]
public DateTime Date;
[DataMember]
public decimal Amount;
}
//
public int UpdateTerm(int id, int documentId, Term[] terms)
{
// it receives the passed Term array with all objects
// but here all the Dates are 01.01.0001 and all Amounts are 0.00
}
I have added all the ServiceContract
, OperationContract
attributes in the Interface.
Why are Dates 01.01.0001 and Amounts 0.00, like the array members were constructed again?
Other services are working OK, there isn't anything specific..
Simplified client code:
Term[] terms = new Term[3];
for (int i = 0; i < rows.Length; ++i)
{
terms[i] = new Term();
terms[i].Amount = 10;
terms[i].Date = DateTime.Now;
}
MyService service = new MyService();
try
{
id = service.UpdateTerm(1, 2, terms);
service.Close();
}
catch
{
service.Abort();
throw;
}