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

Contains query with a subtype ?

1 Answer 70 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.
Jeremy Mann
Top achievements
Rank 1
Jeremy Mann asked on 01 Feb 2010, 10:34 PM
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.
s

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


Help !?

1 Answer, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 04 Feb 2010, 06:04 PM
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>()
  
    where 
        GroupAppointments.Start >= owner.VisibleRangeStart &&
        GroupAppointments.End1 <= owner.VisibleRangeEnd).ToList()
        .Where(g => g.GroupStringArrayOfGroupIDs.Contains(GroupAppointments.AppointmentGroupsCollection[0].UserGroupID
        ).Select(g => g);


Kind regards,
Zoran
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.
Tags
LINQ (LINQ specific questions)
Asked by
Jeremy Mann
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or