I am trying to return a list from my WCF service to the client.
I am using Entity Framework to query against my database
I have the following code in my Entity Framework library :
public List<Users> getUsersByLastName(string pLastName)
{
using (var context = new AMTEntitiesContainer())
{
var users = context.Users
.Where((c) => c.LastName.Contains(pLastName))
.ToList();
return users;
}
}
This is how I am capturing the result in my WCF and returning it :
public List<wcfUser> getUsersByLastName(string pLastName)
{
UserMethods userMethods = new UserMethods();
List<Users> usersList = userMethods.getUsersByLastName(pLastName);
List<wcfUser> usersListForClient = new List<wcfUser>();
wcfUser usersForClient = new wcfUser();
foreach (Users u in usersList)
{
usersForClient = new wcfUser();
TranslateServerUserToClientUser(u, usersForClient);
usersListForClient.Add(usersForClient);
}
return usersListForClient;
}
The thing is, for some reason the usersList is always empty..why so?
I checked that the DB is not empty by throwing the same queries into LINQPad
return usersListForClient;it is filled with data? If so, try updating your service reference.