none
IQueryable from plain SQL? RRS feed

  • Question

  • Hi,

    Is there any chance to construct an IQueryable from plain SQL?
    Without Dynamic Linq nor have to work with Expression tree.
    I sometimes like to write my plain old sql, not the linq query.
    But the Context.ExecutQuery returns only OneTimeEnumerable type, i guess,
    and thus I lost a lot of IQueryable's power.
    So, Had anyone tried this before?

    Thanks,
    Panya
    Monday, November 30, 2009 10:02 PM

Answers

  • Hi Panya,

    Welcome to LINQ to SQL forum!

    It’s an interesting question.  What kind of power do you want use of an IQueryable query?  One important feature is that we can combine several IQueryable query and LINQ to SQL provider can finally create the T-SQL to access the database.   However, I think this feature is built on the Expression Tree we got in each IQueryable queries.  Even the Dynamic LINQ uses the Expression Tree.  So I don’t think the IQueryable query can stand alone without certain Expression Tree generated.  

    Feel free to let me know if you have any questions.

    Have a nice day!


    Best Regards,
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, December 3, 2009 6:39 AM
    Moderator

All replies

  • Hi Panya,

    Welcome to LINQ to SQL forum!

    It’s an interesting question.  What kind of power do you want use of an IQueryable query?  One important feature is that we can combine several IQueryable query and LINQ to SQL provider can finally create the T-SQL to access the database.   However, I think this feature is built on the Expression Tree we got in each IQueryable queries.  Even the Dynamic LINQ uses the Expression Tree.  So I don’t think the IQueryable query can stand alone without certain Expression Tree generated.  

    Feel free to let me know if you have any questions.

    Have a nice day!


    Best Regards,
    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, December 3, 2009 6:39 AM
    Moderator
  • Devart LINQ to SQL implementation contains the Query method constructing IQueryable from the SQL query.
    public IQueryable<TResult> Query<TResult>(string query, object parameter1, 
    object parameter2); 

    Devart Team
    http://www.devart.com/dotconnect
    ADO.NET data providers for Oracle, MySQL, PostgreSQL, SQLite with Entity Framework and LINQ to SQL support
    Tuesday, December 8, 2009 11:36 AM