c# - return a specific datafrom wcf -


my method this:

public list<civartransporteservice.model.cliente> getclientes()     {         using (civartransporteservice.model.civartransportemodelcontainer context = new model.civartransportemodelcontainer())         {             return context.cliente.tolist();          }     } 

and cs:

public interface icatalogsservice {     [operationcontract]     list<civartransporteservice.model.cliente> getclientes(); } 

actually getclientes return fields of clientes database need name of client how this? thx

you can use linq select extension method name column. need update method signature return list of string now.

assuming name property of client entity

public list<string> getclientes() {    using (var context = new model.civartransportemodelcontainer())    {        return context.cliente.select(x=>x.name).tolist();        } } 

and interface signature well

public interface icatalogsservice {     [operationcontract]     list<string> getclientes(); } 

or if not want update existing interface , it's implementation, can @ whererever calling it.

icatalogsservice catalogservice; catalogservice = new someconcretecatalogservice(); // not best "new" up.                                                 // not real question here. var clientnamelist = catalogservice.getclients().select(s=>s.name).tolist(); 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -