Reputation: 563
If i define a Test object, with string and Datetime properties and use it to return IEnumerable(T) collection in WCF
[OperationContract]
IEnumerable<Test> GetTestNotes();
and when calling the service from the client, I see that it is converting the IEnumerable to Test[]:
public Test[] GetTestNotes() {
return base.Channel.GetTestNotes();
}
And Im able to get data.
Question is: How reliable is it to use IEnumerable(T) interface rather than concrete, List(T)?
My clients that consume these WCF services are not only in .NET but also in JAVA.
Upvotes: 2
Views: 2518
Reputation: 149040
If you're using the Visual Studio generated service references, you can pick what type is used for collections. Right-click on the service under Service References and select Configure Service Reference…. You should see these options:
However, this still won't allow you to select IEnumerable<T>
. If you want tighter control over what the client interface looks like, your best bet is to define the contracts in a separate assembly and then reference those assemblies on both the client and server.
Upvotes: 1