我想從wcf服務的數據綁定到網格silverlight應用程序。Silverlight Wcf綁定網格
我正在這樣做。
這是我的服務類
public class Employee
{
public string Adres { get; set; }
public string Country { get; set; }
public string City { get; set; }
public string Region { get; set; }
}
public List<Employee> CustomerList()
{
OracleConnection conn = new OracleConnection("connectionstring");
OracleCommand cmd = new OracleCommand();
var custList = new List<Employee>();
cmd.CommandText = "select * from EMPLOYEES";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
conn.Open();
OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr != null)
{
while (dr.Read())
{
var cust = new Employee
{
Adres = dr.GetString(7),
Country = dr.GetString(11),
};
custList.Add(cust);
}
}
return custList;
}
和Silverlight應用程序代碼
client.CustomerListCompleted += new EventHandler<CustomerListCompletedEventArgs>(client_CustomerListCompleted);
client.CustomerListaAsync();
}
void client_CustomerListCompleted(object sender, CustomerListCompletedEventArgs e)
{
gridControl1.ItemsSource = e.Result[0];
}
這是工作,但我不得不執行多個SQL查詢,我無法實現對每一類one.how我可以做這個任務。
謝謝。
你是什麼意思的「必須執行多個SQL查詢」?除了客戶名單之外,您是否還有其他需要獲取的數據集,並且正在尋找一種將其返回客戶端的優化方法? – KodeKreachor 2012-03-20 00:34:22