I need to convert the result of a stored procedure in a dbml file to IQueryable to view a list in an

Posted by RJ on Stack Overflow See other posts from Stack Overflow or by RJ
Published on 2010-05-06T19:20:30Z Indexed on 2010/05/06 19:38 UTC
Read the original article Hit count: 224

Filed under:
|
|
|
|

I have a MVC project that has a Linq to SQL dbml class. It is a table called Clients that houses client information. I can easily get the information to display in a View using the code I followed in Nerd Dinner but I have added a stored procedure to the dbml and it's result set is of IQueryable, not IQueryable. I need to convert IQueryable to IQueryable so I can display it in the same View. The reason for the sproc is so I can pass a search string tothe sproc and return the same information as a full list but filtered on the search. I know I can use Linq to filter the whole list but I don't want the whole list so I am using the sproc.

Here is the code in my ClientRepository with a comment where I need to convert. What code goes in the commented spot.

        public IQueryable<Client> SelectClientsBySearch(String search)
    {
        IQueryable<SelectClientsBySearchResult> spClientList = (from p in db.SelectClientsBySearch(search) select p).AsQueryable();

        //what is the code to convert IQueryable<SelectClientsBySearchResult> to IQueryable<Client>

        return clientList;
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc