Specifying dictionary key in the WHERE clause

2 posts, 0 answers
  1. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 30 Nov 2009 Link to this post

    Hi
    What is the syntax in OQL to query on the value of a key of a dictionary that belongs to a parent class. Say I have a Person class with a dictionary<string,Address> Addresses where Address is a persisted class. What would be the correct OQL for "select * from PersonExtent as P where P.Addresses['Home'] != null"?
    Thanks
    James Denning
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Dec 2009 Link to this post

    Hello James Denning,

    Unfortunately that is not possible using OQL. I would suggest you to use LINQ as a workaround. So for example if you have a class called persons that has a dictionary property called dict a query that would be accessing the dictionary keys would look something similar to that:
    var result = from c in scope.Extent<Person>()
                            from f in c.Dict.Keys
                            where f == 1
                            select c;


    Best wishes,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
Back to Top