Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using ServiceStack.OrmLite v4.0.62 because of .NET Framework 4.0. I need to perform search functionality. As my POCO classes have deep hierarchy, I need to use LINQ queries with nested subqueries. E.g.:
C#
// some code is omitted
Expression<Func<Person,bool>> condition = p => p.Name.Contains("John") &&
p.Addreses.Any(adr => adr.City.Contains("Moscow") && adr.Street.Contains("Yuri Gagarin") && adr.Building == 23); // and so on...

// some code is omitted

// Gets the quantity of records were found
public int GetCountBy(Expression<Func<T,bool>> condition)
{
    // here it throws an Exception
    return db.Persons.Count(condition);
}

And now it throws an Exception:
C#
variable 'person' of type 'Reestr.DAL.Entities.Person' referenced from scope '', but it is not defined

Same exception is thrown when we use another method which supports Expression as parameter. My questions are: How can I solve that problem? Does OrmLite supports such queries?

What I have tried:

I've tried to create my Expression manually but it doesn't helps me. Also I've tried to use another OrmLite methods.
Posted
Comments
Mehdi Gholam 20-Dec-16 1:06am    
Try contacting the original author(s).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900