我有一个返回自定义类(用户)的对象的Web服务:
Web服务代码
public class User
{
public string login { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
}
[WebMethod]
public User GetUserInfo(int userID)
{
ITDashboardDataContext db = new ITDashboardDataContext();
User usr = (from u in db.tl_sb_users
where u.userID == userID
select new User
{
firstName = u.firstName,
lastName = u.lastName,
email = GetUserEmail(userID),
login = u.login
}).FirstOrDefault();
return usr;
}
我想投的结果作为用户对象时,我打电话从其他应用程序的Web服务(我已经重新定义在此应用程序的用户类,太):
调用应用程序代码
public class User
{
public string login { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
}
我想带回一个用户对象与此:
RolloutWriter.RolloutWriter rw = new RolloutWriter.RolloutWriter();
rw.Credentials = new NetworkCredential("myuser", "mypassword", "mydomain");
var vu = rw.GetUserInfo(userID);
User u = (from v in vu
select new User {
email = vu.email,
firstName = vu.firstName,
lastName = vu.lastName,
login = vu.login
}).FirstOrDefault();
这并不工作 - 它告诉我:
Could not find an implementation of the query pattern for source type 'amstaffsite.RolloutWriter.User'. 'Select' not found.
我怎样才能得到一个用户对象?