I have a web service that returns an object of a custom class (user):
Web service code
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;
}
I want to cast the result as a user object when I call the web service from another application (I've redefined the user class in this app, too):
Calling application code
public class User
{
public string login { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
}
I'm trying to bring back a user object with this:
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();
this doesn't work - it tells me:
Could not find an implementation of the query pattern for source type 'amstaffsite.RolloutWriter.User'. 'Select' not found.
How can I get back a user object?