Reputation: 702
I have WCF service where I am processing Customer object and based on that I need to send array of Products related to customer.
So I question is, if there is no products for particular Customer should I return the Null value or empty array of Products to the WCF Client?
Please advise the best approach to do this.
[OperationContract]
Product[] DoProcess(Customer customer);
if(Product not found by Customer)
{
// return null;
// or
// return new Product[];
}
Many thanks in advance.
Upvotes: 2
Views: 384
Reputation: 2797
There is no correct answer for that.
If you choose to return nulls on your environment as a "not found", it is ok. If your app is expecting empty arrays, go ahead.
Upvotes: 2
Reputation: 7601
it's better to return new Product[]
so at the client side you don't need to check the condition of null.
Upvotes: 2