English 中文(简体)
超过一种数据类型
原标题:return more than one data type

I query-ing this from entity framework using WCF, and i want to use the data in phone client side, may i know how can i query more than one data type from the WCF function ?

[OperationContract]
string LoginUser(string email, string password);

ISER.cs

        public string LoginUser(string email, string password)
    {
        string query = @"SELECT VALUE tblUser FROM MyEntities.tblUsers AS tblUser WHERE tblUser.email = @email AND tblUser.password = @password";
        ObjectParameter[] parameters = new ObjectParameter[2];
        parameters[0] = new ObjectParameter("email", email);
        parameters[1] = new ObjectParameter("password", password);

        using (var context = new SteamKingEntities())
        {
            ObjectQuery<string> results = context.CreateQuery<string>(query, parameters);
            foreach (string result in results)
            {
                if (result != null)
                {
                    return result;
                }
            }
        }
        return null;
    }

Iservice.svc.cs

        public Login()
    {
        InitializeComponent();
        _serviceClient = new Service1Client();
        _serviceClient.LoginUserCompleted += new EventHandler<LoginUserCompletedEventArgs>(_serviceClient_LoginUserCompleted);

    }

    private void loginBtn_Click(object sender, RoutedEventArgs e)
    {
        _serviceClient.LoginUserAsync(txtEmail.Text, txtPassword.Password);
    }

    private void _serviceClient_LoginUserCompleted(object sender, LoginUserCompletedEventArgs e)
    {

        if (e.Error == null && e.Result != null)
        {
            MessageBox.Show("Welcome " + e.Result + "!");
        }
        else
        {
            MessageBox.Show(e.Error.Message + " Couldn t Login, Please try again =D");
        }
    }

login.xaml.cs

我要从实体框架中回到整个桌子,让我在温得和的电话方面逐一处理。

我猜想,需要对ISER方面作一些修改,但我并不严重地知道如何因为一把新电话投向Linq至Q。 请指导我如何为返回做像样的事情。 谢谢。

<>Update>

页: 1 在试图将参数(http://tempuri.org/:LoginUserResult)淡化时有错误。 详情请见InnerException。

i 将该守则修改为。 WCF 习俗目标,但不能将其erial化...... i 猜测这一问题来自WP部分,how 能够使结果化为乌有?

最佳回答
问题回答

您需要使用数据合同:

[DataContract]
    public class ReturnType
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string Pass { get; set; }
    }

它希望:

[OperationContract]
    Entities.ReturnType[] SelectTopUser(int countOfTop);

返回类型可以是实体框架类型





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...