none
StackOverflowException in LINQ to SQL RRS feed

  • Question

  • We are using LINQ to SQL to work with database in our project and almost all is fine but one thing: sometimes we have to build a huge WHERE condition using some universal query object which is built by user input.

    To build the predicate to put in WHERE statement we used tricks explained here http://www.albahari.com/nutshell/predicatebuilder.aspx but expression built in such a way makes LINQ to SQL throwing StackOverflowException if WHERE predicate includes too many conditions (several hundreds actually) when it is converting resulting expression into SQL query.

    Is there a way to build LINQ expression with bunch of conditions so that LINQ to SQL treats it well?
    Tuesday, October 13, 2009 2:18 PM

Answers

  • There are a few reasons why this could be happening:
    1. Unbalanced expression tree
    2. Malformed expression tree
    3. Query is just too big for LINQ to SQL to handle
    4. Query is being misunderstood by LINQ to SQL
    Best thing to do would be to email me the stack trace and if possible the expression tree.  You can send it to damiengu at microsoft.com

    [)amien
    • Marked as answer by Yichun_Feng Tuesday, October 20, 2009 1:16 AM
    Tuesday, October 13, 2009 2:50 PM
    Moderator

All replies

  • There are a few reasons why this could be happening:
    1. Unbalanced expression tree
    2. Malformed expression tree
    3. Query is just too big for LINQ to SQL to handle
    4. Query is being misunderstood by LINQ to SQL
    Best thing to do would be to email me the stack trace and if possible the expression tree.  You can send it to damiengu at microsoft.com

    [)amien
    • Marked as answer by Yichun_Feng Tuesday, October 20, 2009 1:16 AM
    Tuesday, October 13, 2009 2:50 PM
    Moderator
  • Hi Damien,

    I've sent you e-mail. Will be greatly appreciated to get any feedback.
    Wednesday, October 14, 2009 11:24 AM