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);
IService.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
I want to return the entire table from Entity Framework and allow me to process one by one in Window Phone side.
I guess i need to do some modification to the IService side but i seriously don’t know how because i’m new to phone development and used to Linq to SQL. Can you please guide me on how to make something like type for the return, Please. Thank you.
Update
The error i get There was an error while trying to deserialize parameter http://tempuri.org/:LoginUserResult. Please see InnerException for more details.
i was modified the code into the way stated in WCF Custom Object but i could not deserialize it… i guess the problem came from the WP part, how could i deserialize the result ?
You can use ref or you can use custom-objects