c# - Entity Framework returning empty values -


i trying return list wcf service client.

i using entity framework query against database

i have following code in 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 how capturing result in wcf , returning :

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, reason userslist empty..why so?

i checked db not empty throwing same queries linqpad

this solved it, apparently db returning weird captured :

private amtentitiescontainer context = new amtentitiescontainer();  public ienumerable<users> getusersbylastname(string plastname) {     iqueryable<users> results;      results = (from m in context.users                m.lastname.startswith(plastname)                select m);      return results; } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -