Contains in LINQ expression generates error

3 posts, 0 answers
  1. jgulin
    jgulin avatar
    2 posts
    Member since:
    Nov 2006

    Posted 24 May 2010 Link to this post

    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. jgulin
    jgulin avatar
    2 posts
    Member since:
    Nov 2006

    Posted 26 May 2010 Link to this post

    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!
  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 26 May 2010 Link to this post

    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.
Back to Top