LINQ inner query in ORM not work properly

3 posts, 0 answers
  1. Amin
    Amin avatar
    4 posts
    Member since:
    May 2013

    Posted 30 Jun 2013 Link to this post

    Hello My friends.
    I'm using open access ORM in my project and have a trouble problem with linq navigation,
     this is my query :
     
    var sabet = context.tbl1.Where(i => i.JalaseMSID == JalaseMSID.ToInt() &&
                                  (i.tblAezayeJalases ==
    null || (i.tbl2 != null &&
                                   i.tblAezayeJalases.Any(j => j.tblJalaseID == jalaseID))));

    but, when i'm using
    int c = sabet.Count();
      to retrieve result count, i got a error message :
    Telerik.OpenAccess.RT.sql.SQLException: Subquery returned more than 1 value.
    This is not permitted when the subquery follows =, !=, <, <= , >, >= or
    when the subquery is used as an expression.
    ithink the problem is in inner query(i.tblAezayeJalases.Any) but it return boolean value and no matter how many records being returned,
    what can i do?
  2. Amin
    Amin avatar
    4 posts
    Member since:
    May 2013

    Posted 30 Jun 2013 Link to this post

    i fix this problem with replacing :
    i.tblAezayeJalases.Count == 0

    instead of
    i.tblAezayeJalases == null
    :)
  3. DevCraft banner
  4. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 02 Jul 2013 Link to this post

    Hi Amin,

    I am glad to see that you have found the problem. Indeed, the collections of the persistent classes are always initialized and there is no need to do null checks.

    Regards,
    Alexander
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top