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

Contains in LINQ expression generates error

2 Answers 63 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.
jgulin
Top achievements
Rank 1
jgulin asked on 24 May 2010, 03:38 PM
I have wrote this code and when I run it it generates this error:

BackendQuery = '(result).BackendQuery' threw an exception of type 'Telerik.OpenAccess.OpenAccessException'

var dates = new List<string>(); 
     
            foreach (RadDate rD in dTC) 
            { 
                dates.Add(rD.Date.ToString()); 
            } 
             
            var result = from a in scope.Extent<Proj>() where dates.Contains(a.ETADate)  
                         orderby a.ETADate descending, a.ArriveTime descending 
                         select a;

Any ideas why this is not working?

2 Answers, 1 is accepted

Sort by
0
jgulin
Top achievements
Rank 1
answered on 26 May 2010, 08:45 AM
solved:

var dates = new List<DateTime>(); 
     
            foreach (RadDate rD in dTC) 
            { 
                dates.Add(Convert.ToDateTime(rD.Date)); 
            } 
 
            var result = from a in scope.Extent<Proj>() 
                         where dates.Contains((DateTime)a.ETADate) 
                         orderby a.ETADate descending, a.ArriveTime descending 
                         select a; 

works!
0
Zoran
Telerik team
answered on 26 May 2010, 06:14 PM
Hi jgulin,

Good to know that you have solved your problem. I am not sure about the cause of the exception as I am not sure about the types that you are having inside your model. Is the ETADate property of type string or DateTime? Maybe it was a cast problem on he database server, but we will have to investigate it further.

All the best,
Zoran
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
jgulin
Top achievements
Rank 1
Answers by
jgulin
Top achievements
Rank 1
Zoran
Telerik team
Share this question
or