Doing something like that is not simple. Have a look at the series of articles Building an IQueryable provider by Matt Warren. All the code he uses is available as a library too. That should help you get started.
You could write an expression tree parser and generate the sql. Your description contains a fault -
IQueryable<Cat>, it is an
IEnumerable<Cat>. As you tagged it correctly, this is linq-to-objects, not linq-to-sql. There is no information in the calls to construct a query.
Check out the method DataContext.GetCommand() which is passed an IQueryable object and returns the DbCommand object that corresponds to the query. The CommandText property of the DbCommand object shows the text of the query.
- convert linq to object query to sql query (no linq to sql code or datacontext)
- Determine the source DataContext for a Linq to Sql query
- Convert Linq Data query to object type
- Convert this LINQ code back to a Loop (or Why is this object sometimes null)
- Cannot implicitly convert type System.Collections.Generic.List back to Object after linq query
- Convert SQL update query to c# LINQ code
- Convert Linq Query Result to Dictionary
- Convert string to int in one line of code using LINQ
- Iterate through properties and values of an object returned via a linq query on a domain model
- How to convert LINQ query result to List?
- Convert an IQueryable linq query to IEnumerable<T> cancels out linq optimized way to work?
- How can I convert Linq results to DTO class object without iteration
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- How to Convert LINQ Comprehension Query Syntax to Method Syntax using Lambda
- Convert linq query to string array - C#
- Convert SQL to LINQ Query
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- Convert string to int in an Entity Framework linq query and handling the parsing exception
- LINQ Query to Convert string to datetime
- convert string to DateTime in linq query with where clause?
- Convert string to decimal in group join linq query
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- Fastest way to fill DataTable from LINQ query using DataContext
- LINQ SQL query check if a object field is not null
- LINQ Query - How to map a resultset into another object using Select
- Linq query a List of objects containing a list of object
- Problem with LINQ to Entities query using Sum on child object property
- Convert string array to custom object list using linq
- Convert KeyValuePair to anonymous type in a LINQ query
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Transform a List<object> of anonymous type to a Dictionary<string, SortedList<DateTime, double>>
- How to get the count from IQueryable
- LINQ to Dataset DBNULL problem / null reference exception
- Finding a specific node using Xpath and Linq
- Create array from nested lists
- LINQ to SQL query succeeds or fails based on using foreign key versus using a built in navigation property
- Linq to XML to Generate DDLs
- c# deserialize json to list results in null when json is empty?
- Best Practice for Creating A - Z Index using Linq in Asp.net
- Error getting too many character literals
- remove duplicates from linq query c#
- Linq GROUP & SUM the same columns from different tables
- The type of one of the expressions in the join clause is incorrect when the types are the same
- show all linq sql queries per request
- LINQ and Dictionary Thread Safety
- Automapping error: The type does not have a default constructor
- select multiple column from include table in LINQ
- How to "split up" or optimize a Linq to Sql query.
- c# group list into new list
- Is it possible to remove columns in select query