Entity Translation

Topics: CAB & Smart Client Software Factory
Aug 14, 2006 at 4:59 AM
originally posted by: MichaelDaniel

I have a web service that is returning a generic List<> collection of objects as a property of my main object.
I am now running into issues where the Entity Translator service has converted all my generic lists into arrays (or more to the point I think it is the Add Web Service recipe that has done the conversion, but the problem shows up during Entity Translation)

I have a few questions around this:
1) As a rule of thumb/ best practice should I be returning generic lists in a Web Service in the first place? If not: why not?
2) As an experiment I tried converting the returned generic lists to arrays, and re-generating the web service reference/recipe. I then found I still have problems whenever my web service objects contain nested collections of other objects.
3) What is the best way around this? I really don't want to make multiple web service calls to saturate nested business objects that I can retrieve in one call.

Sorry for so many questions: if someone could provide some guidance on how to translate the following (example) object returned from a web service it would be greatly appreciated.

public class Author
public int Id;
public string Name;
public AddressDetails Address;
public List<Book> Publications;

I would assume that you would have a seperate translator object for each of these objects (in this example: Author, Address, Book)
It then started getting kinda nasty regardless of whether Publications were an array or List<> :(
Aug 14, 2006 at 2:44 PM
originally posted by: MichaelDaniel

I can answer some of my own questions now...
1) Generic Lists in Web Services are 'downgraded' to Arrays by design. This is to cater for non-generic capable clients (eg .NET1.1 clients). (I'm not sure this is 100% correct but anyway)
2) From the BankBranch example: if (value.Addresses != null) result.Addresses = service.Translate<Address[]>(value.Addresses);

Sorry, It was getting late and I should have done some more research before unloading on the forum ;)