Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

How to return list from wcf to silverlight file

$
0
0

Hi 

WCF -

public List<Department> department_names()
{
List<Department> list = new List<Department>();
string deptnames = "Select dept_id,department_name from Department";
con.Open();
DataRow r = null;
cmd = new MySqlCommand(deptnames, con);
da = new MySqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, "Department");
dt = new DataTable();
dt = ds.Tables[0];

foreach(DataRow d in dt.Rows)
{
Department dpt = new Department();
r = d;
dpt.dept_id = Int32.Parse(r[0].ToString());
dpt.dept_name = r[1].ToString();
list.Add(dpt);

}
con.Close();
return list;

}

here Department is a class of get and set.

in service.cs

[OperationContract]
List<Department> department_names();

Now in.cs file

I tried to retrieve like below

var d = new ServiceReference1.LibrayClient();
d.department_namesCompleted += new EventHandler<ServiceReference1.department_namesCompletedEventArgs>(department_names);
d.department_namesAsync();

void department_names(object sender, ServiceReference1.department_namesCompletedEventArgs e)
{

e.result;

}

I want to retreive the list ?


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>