Contains query with a subtype ?

Thread is closed for posting
2 posts, 0 answers
  1. Jeremy Mann
    Jeremy Mann avatar
    23 posts
    Member since:
    Jul 2009

    Posted 01 Feb 2010 Link to this post

    I'm having a problem trying to get OpenAccess / LINQ to do an IN or CONTAINS on a field of a subtype collection.  This is for my radscheduler.

    I have two classes  ScheduledAppointment and UserGroup the two are joined as a m:n collection  (scheduledappointment being the owner).   I have a string array of groupID's and I need to get the record for any group that has a groupID contained in the arraylist.

    obviously I cannot use the index of AppointmentGroupsCollection[0] so I'm unsure of how to accomplish this.   I tried doing a sub-where with a predicate but It didn't like that either.

    //----Add All The Group Appointments To the Calendar------------------- 
    var GroupAppointmentsToShow =  
        from GroupAppointments in Scope.Extent<mynamespace.Entity.ScheduledAppointment>() 
            GroupAppointments.Start >= owner.VisibleRangeStart && 
            GroupAppointments.End1 <= owner.VisibleRangeEnd && 
        select GroupAppointments; 

    Help !?
  2. Zoran
    Zoran avatar
    534 posts

    Posted 04 Feb 2010 Link to this post

    Hi Jeremy Mann,

    These kind of queries are not processed on the database server at the moment. You could use a workaround that performs the last part of the operation on the client side. Here is an example code:
    var GroupAppointmentsToShow = 
        (from GroupAppointments in Scope.Extent<mynamespace.Entity.ScheduledAppointment>()
            GroupAppointments.Start >= owner.VisibleRangeStart &&
            GroupAppointments.End1 <= owner.VisibleRangeEnd).ToList()
            .Where(g => g.GroupStringArrayOfGroupIDs.Contains(GroupAppointments.AppointmentGroupsCollection[0].UserGroupID
            ).Select(g => g);

    Kind regards,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top