Tuesday, 15 September 2015

c# - Merging two list from different WCF ServiceClients which have the same object-type -


I have an orbit library that has a class named "club" in which two WCF services are used by each one The same return type is a list of club-object: list & lt; Club & gt; .

When I call both methods in a webform, then with two lists, these club objects, I can not merge those lists with the help of the concert because a list is viewed as a service list 1. She goes. List Club & gt; and another is seen as a serviceclatient 2. List and not just list & lt; Club & gt; .

  var resultService1 = service1Client.GetClubByName (search) .toList (); Var resultService2 = service2Client.GetClubByName (search) .toList (); Var endResult = resultService1.Concat (resultService2);  

I have tried to change var with casting and specific object type, but with no results. How can I decide this because I want to show results in a grid from both services.

Thanks in advance!

A solution is to create a new anonymous type in which you have the necessary properties.

  var endResult = resultService1 Select (x = & gt; new {x.Prop1, x.Prop2}) .Concat (select resultService 2. Select (x => New {x.Prop1, x.Prop2}));  

No comments:

Post a Comment