Is there a plan to make Dapper.net compatible with IQueryable interfaces? If not, what's the workaround to use Dapper with "Expression Trees" filters?
            Asked
            
        
        
            Active
            
        
            Viewed 2.4k times
        
    35
            
            
        - 
                    Surely a question about the future of Dapper.Net would be better placed on github? – samjudson Dec 19 '14 at 10:00
 - 
                    2This is a feature request for an external library. – erikkallen Dec 19 '14 at 10:06
 - 
                    1At nearly 1,000 reputation, you should know the rules by now. This is completely offtopic. – JK. Dec 21 '14 at 11:31
 - 
                    Some may quibble about whether this question satisfies the rules, but it asked a question I was looking for, and the answer was helpful. – Nick Mar 20 '17 at 16:30
 - 
                    Excellent question, I will be working with Dapper soon, my first question was what is it? and my second question was exactly this one! – Ibrahim ben Salah May 05 '18 at 19:19
 - 
                    What solution did you end up with Bill? As you might be looking for a faster performing solution then the default EF behavior? – CularBytes May 01 '19 at 14:06
 - 
                    Any updates to this, given there several years passed by – NitinSingh Sep 07 '21 at 15:23
 
3 Answers
59
            No, there are no plans to do this. It is far far outside what dapper tries to do. So far that I would say it is antithetical. Dapper core tries to be the friend to those who love their SQL.
        Marc Gravell
        
- 1,026,079
 - 266
 - 2,566
 - 2,900
 
- 
                    Great answer - If any doesnt like SQL, there are other solutions like Entity Framework. – Nils Anders Dec 30 '14 at 08:33
 - 
                    5I really like SQL (or I really like to like SQL). but i also like getting paid early. Screw SQL, i want to deploy. Entity Framework for SQLite it is! – jokab Aug 25 '16 at 04:47
 - 
                    7I'm sorry SQL, I really meant screw OData! Forgive me, I'm crawling back to your arms! – jokab Aug 25 '16 at 04:56
 
-2
            
            
        You can get IQueryable from IEnumerable using the built-in extension method  AsQueryable in  System.Linq namespace
public IQueryable<Order> GetOrdersAsQuerable()
{
    IEnumerable<Order> qry= GetOrders(); //using Query<T>
    //use the built-in extension method  AsQueryable in  System.Linq namespace
    return qry.AsQueryable();            
}
        M.Hassan
        
- 10,282
 - 5
 - 65
 - 84
 
- 
                    22But it won't be a real IQueryable object and so it doesn't have any benefits. – kipusoep Jan 09 '18 at 17:23
 - 
                    2yes, but you can use the IQueryable version to bind, for example GridView in Asp.net and benefit for sorting (you can't sort using IEnumerable version). – M.Hassan Jan 09 '18 at 22:01
 - 
                    2Sure, it's pretending to be an IQueryable object, but we all know it isn't and AFAIK the benefits of a real IQueryable do not apply if you mock it, right? – kipusoep Jan 10 '18 at 06:22
 - 
                    1The value of `IQueryable ` in e.g. EF or linq2Sql is lazy executing to the last minute and generate sql that sent to the server. but, the story is different in Dapper. In Dapper you do all filters in a parametric sql statement using `Query
` and get `IEnumerable`. You gain extra benefit by using `AsQuerable` and get dynamic sorting that you have to implement it without `AsQuerable`. see: https://stackoverflow.com/questions/1106802/why-use-asqueryable-instead-of-list#comment8817475_4096467 – M.Hassan Jan 11 '18 at 00:26 - 
                    This is not the expected behavior JK. seems to want. This is just a cast, JK. seembs to want a EF behavior creating the Query dynamically. – gatsby Sep 03 '18 at 07:13