Filtering problem when using IQueryable

2 posts, 1 answers
  1. FISCAL
    FISCAL avatar
    91 posts
    Member since:
    May 2010

    Posted 15 Jul 2010 Link to this post

    HI,

    I am using IQueryable approach to create dynamic query. All seems okay apart from OpenAccess not supporting something like..

    ..
      if (m_dataContext.Transaction.IsActive == false) m_dataContext.Transaction.Begin();
                IQueryable<AdmAudit> audits = m_dataContext.Extent<AdmAudit>();
                if (dateTo.HasValue)
                {
                    //Convert.ToDateTime is not supported in where clause to it needs to be converted before passing it
                    //OpenAccess implementation lacking
                    dateTo = Convert.ToDateTime(dateTo).Date;
                    audits.Where(audit=> audit.AdmAuditRecordEntered <= dateTo);
                }
    //Search for string..
                   audits = audits.Where(audit => audit.Log.Contains(strSeachString));
    Above bold instruction is failing.

    Any help would be highly appreciated.

    Many thanks.

    M G

  2. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 15 Jul 2010 Link to this post

    Hi M G,

    I think the issue is that in the (potential) first invocation the audits variable is not updated with the new queryable instance that contains the date filter. You did that for the second .Where() though!

    Sincerely yours,
    Thomas
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top