Silverlight 5 Pivot Viewer通过WCF连接到MySQL

时间:2014-08-09 16:50:52

标签: c# mysql wcf silverlight pivotviewer

我在Silverlight 5中创建了Pivot查看器客户端,我的Service类如下所示。如何将Pivot.ItemsSource分配给下面的此服务类?我已经添加了服务引用,但无法将数据从MySQL数据库传递到数据透视表查看器。非常感谢任何帮助。

public class Service1
{
    [OperationContract]
    public void DoWork()
    {
        // Add your operation implementation here
        return;
    }

    // Add more operations here and mark them with [OperationContract]

    [OperationContract]
    public List<Employee> GetAllEmployees()
    {
        var emps = new List<Employee>();
        string connect = ConfigurationManager.ConnectionStrings["yoyo"].ToString();
        using(var con = new SqlConnection(connect))
        {
            string query = "Select simpleid,brand FROM bob_reporting_sg.pivottable";
            var cmd = new SqlCommand(query, con);
            con.Open();
            using (var dr = cmd.ExecuteReader())
            {
                while(dr.Read())
                {
                    var emp = new Employee();
                    emp.EmployeeID = dr.GetInt32(0);
                    emp.FirstName = dr.GetString(1);
                    emps.Add(emp);

                }
            }
        }

        return emps; 
    }
}

0 个答案:

没有答案