This is a migrated thread and some comments may be shown as answers.

Filtering problem when using IQueryable

1 Answer 79 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FISCAL
Top achievements
Rank 1
FISCAL asked on 15 Jul 2010, 12:24 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Thomas
Telerik team
answered on 15 Jul 2010, 01:40 PM
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
Tags
LINQ (LINQ specific questions)
Asked by
FISCAL
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or