问题描述
你好,
我是WCF的新手.我想创建一个连接到WCF服务的简单桌面登录应用程序[该服务用于连接到SQL Server,并使用Linq to Entities获取需要的数据],并验证是否存在该用户.我有以下事情.
1)使用1个名为GetUserDetails(sting userName)的函数创建了WCF服务.
Hello,
I am new to WCF. I wanted to created a simple desktop login application that connects to WCF service [Service is used to connect to SQL server and get requires data using Linq to Entities] and verifies wheather user existed or not. I have following the following things.
1) Created a WCF service with 1 function Named GetUserDetails(sting userName)
public List<AuthenticationModel> GetUserDetails(string UserName)
{
RiverEntity RiverEntity = new RiverEntity();
List<AuthenticationModel> users = (from p in RiverEntity.Users
where p.UserName == UserName
select new AuthenticationModel
{
UID = (int) p.UID,
ULastName = p.ULName,
UFirstName = p.UFName,
UMiddleName = p.UMName,
UserDMID = p.UserDMID,
UserName = p.UserName,
Password = p.Pass,
Active = (bool) p.Active,
Role = (int) p.Role,
Practices = p.Practices,
RegisteredEmail= p.RegisteredEmail,
DynaIP = p.DynaIP,
LoggedInStatus = p.loggedInStatus,
AppID = p.AppID,
ResetPass = (bool) p.ResetPass
}).ToList<AuthenticationModel>();
return users;
}
2)为我的数据库的实体添加了Linq
3)创建WPF应用程序,并将服务引用添加到我的WPF客户端应用程序.
通过使用WCF测试客户端,我可以从数据库中获取用户详细信息.
现在我想从WPF做到这一点.谁能解释我如何创建代理,调用上述函数并将检索到的值存储到WPF最终属性中.
提前谢谢.
chowdary.
2) Added Linq to Entities for my DB
3) Created WPF application and added the service reference to my WPF client application.
By Using WCF test client i am able to get user details from Data base.
Now i wanted to do this from WPF. Can anybody explain me how to create proxy, call the above mentioned function and stores the retrived values into the WPF end properties.
Thanks in advance.
chowdary.
推荐答案
ServiceReference1Client clientObj = new ServiceReference1Client();
然后
and then
var result = clientObj.GetUserDetails("your parameter");
现在,您可以将其直接绑定到接受该集合的任何对象.
Now, you can directly bind it to any object which takes the collection.
ThreeServiceRef.YourClass obj = new ThreeServiceRef.YourClass();
var result = clientObj.GetUserDetails("your parameter");
这篇关于WCF服务-来自客户端的呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!