Dear Support Team,

We are using DO version 4.4.3 and we are writing really complex and long lambda expressions. Recently we got a lot of StackOverFlow exceptions when trying to execute queries.

As an example the following method

    public static Expression GetFilterByUserExpression(ParameterExpression param)
    {
        if (Andalus.Security.User.GetCurrentUser().ShowOwnedDocumentsOnly)
        {
            var property = Expression.Property(param, "CreatedBy");
            IQueryable<string> list = null;
            var sess = DomainManager.DemandCompanySession();
            try
            {
                using (sess.DisableSaveChanges())
                {
                    list = Employee.GetGetHierarchicalEmployeesSubordinatesIncludingUsername(Andalus.Security.User.Current);
                    return Expression.Call(typeof(Enumerable), "Contains", new Type[] { typeof(string) }, list.Expression, property);
                }
            }
            finally
            {
                DomainManager.RestoreLastSession();
            }
        }
        return null;
    }

The final query expression is

{All().Where(ent => System.Linq.Enumerable+<DistinctIterator>d__81`1[System.String].Contains(ent.CreatedBy)).Where(ent => ent.BusinessUnitCode.StartsWith("1-02")).OrderBy(ent => ent.CreatedOn)}

when evaluating this query we get StackOverFlow exception.

I there something wrong in this query?

asked Mar 21 '13 at 14:13

Fawzy's gravatar image

Fawzy
5123

edited Mar 21 '13 at 14:18

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Hello Fawzy,

our LINQ translator is essentially recursive. This means it will overflow stack given sufficiently big expression. However your expression does not look so at all. Since all work is done in GetGetHierarchicalEmployeesSubordinatesIncludingUsername method it's hard to say what is the problem without seeing its source first.

(Mar 21 '13 at 14:39) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Hello Denis, should I send you the DLL for our model and its dependencies, and if so please give me the mailing address and any related information you need me to include in the mail.

(Mar 24 '13 at 03:55) Fawzy Fawzy's gravatar image

Hello Fawzy, I think it would be better to provide GetGetHierarchicalEmployeesSubordinatesIncludingUsername method source either here or via e-mail: support@dataobjects.net

(Mar 25 '13 at 04:39) Denis Krjuchkov Denis%20Krjuchkov's gravatar image
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×2

Asked: Mar 21 '13 at 14:13

Seen: 3,940 times

Last updated: Mar 25 '13 at 04:39

powered by OSQA