如何将数据从wcf序列化到Windows Phone [英] how to serialize data fom wcf to windows phone

查看:109
本文介绍了如何将数据从wcf序列化到Windows Phone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在wcf中,我正在使用此代码

in wcf i am using this code

public List<customer> login(string salesmanname, string usercode)
{
    List<customer> customers = new List<customer>();
    con.Open();
    using (SqlCommand cmd = new SqlCommand("Select Id, CompanyRefId from SalesMan where salesmanname=@salesmanname and code=@usercode", con))
    {
        cmd.Parameters.AddWithValue("@salesmanname", salesmanname);
        cmd.Parameters.AddWithValue("@usercode", usercode);
        using (SqlDataReader reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                customer c1 = new customer();
                c1.id = (int)reader["Id"];
                c1.companyrefid = (Guid)reader["CompanyRefId"];
                customers.Add(c1);

            }
            return customers;
        }

    }
}



在Windows Phone中,我正在使用此代码



in windows phone i am using this code

string username = salesmannames.SelectedItem.ToString();
               string password = textBox1.Text.ToString();
                proxy.loginAsync(username, password);
                proxy.loginCompleted += new EventHandler<loginCompletedEventArgs>(loginfn);

void loginfn(object sender, loginCompletedEventArgs e)
       {
           if (e.Result != null)
           {
               customer ad = new customer();


               NavigationService.Navigate(new Uri("/customernames.xaml", UriKind.Relative));
           }
       }



我想设置id = 1
and companyrefid = 13444;
如何在Windows Phone代码中执行此操作?



i want to set id = 1
and companyrefid= 13444;
how to do that in windows phone code ?

推荐答案

可以有不同的方法,但是首先请查看http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx [ ^ ].

我之所以提到数据合同",是因为您专门询问了数据序列化问题,但这还不是全部.无论如何,从本质上讲,没有从WCF到Windows Phone"这样的事情,因为您可以在Windows Phone上使用WCF,因此可以使用服务合同和其他所有内容.请参阅:
http://blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx [
There can be different ways, but first of all, look at http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[^].

I mentioned Data Contracts because you asked specifically on data serialization, but that''s not all. Anyway, essentially, there is no such thing as "from WCF to Windows Phone", because you can use WCF on Windows Phone, so you can use service contracts and everything. Please see:
http://blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx[^].

—SA


这篇关于如何将数据从wcf序列化到Windows Phone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆