I am using 3 Tier Architecture in which there is a service layer that have the connection.
I have UserViewModel as the presentation model and user as model from EF
Below is my sample code
public IQueryable<user> GetUsers()
{
entities.Configuration.ProxyCreationEnabled = false;
var query = from u in entities.users
select u;
return query;
}
private IEnumerable<UserViewModel> GetUsers()
{
var database = new entities();
return database.users.Select(user => new UserViewModel
{
UserID = user.UserID,
UserName = user.UserName,
Password = user.Password,
Profile = user.Profile,
Active = user.Active,
});
}
The code must be like the following:
UserViewModel userViewModel= userService.GetUser();
return userViewModel;
How can it be possible to return IQueryable from calling the service layer and bind it to the UserViewModel?