Filter on collections

4 posts, 0 answers
  1. Madhu
    Madhu avatar
    2 posts
    Member since:
    Feb 2011

    Posted 15 Feb 2011 Link to this post

     

    I have a persistent class PhysicalResourceSpecAtomic  and another persistent class PhysicalResourceSpecComposite
     which has a variable CaptivePhysicalResourceSpecCollection which is persistent
     which has a collection of PhysicalResourceSpecAtomic
    and I have definde the collection to be in a association table as 1:n

    Now I want to get a list of PhysicalResourceSpecAtomic 
      which are not in collection CaptivePhysicalResourceSpecCollection.


    Thanks
    Madhu Rao

  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 17 Feb 2011 Link to this post

    Hi Madhu,

    You could use the IList.Contains(object) method to determine whether the CaptivePhysicalResourceSpecCollection contains a specific value:
    IList<PhysicalResourceSpecAtomic> resultList = context.PhysicalResourceSpecAtomicEndPointName.Where(x => !physicalResourceSpecComposite.CaptivePhysicalResourceSpecCollection.Contains(x));

    Hope that helps.

    Regards,
    Damyan Bogoev
    the Telerik team
  3. DevCraft banner
  4. Madhu
    Madhu avatar
    2 posts
    Member since:
    Feb 2011

    Posted 17 Apr 2011 Link to this post

    Damyan,
    I am using Scope.Extent to generate the sql. Also what is the "EndPointName appended at the end of the class PhysicalResourceAtomic. Can you send me the syntax in vb.net.

    Thanks
    Madhu Rao
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 18 Apr 2011 Link to this post

    Hi Madhu,

    The filter query syntax in VB.NET is:

    Dim resultList As IEnumerable(Of PhysicalResourceSpecAtomic) = scope.Extent(Of PhysicalResourceSpecAtomic)().Where(Function(x) Not physicalResourceSpecComposite.CaptivePhysicalResourceSpecCollection.Contains(x))

    An endpoint is an IQueryable collection exposed by the OpenAccessContext which allows accessing the instances of the corresponding persistent capable type.
    Hope that helps.

    Regards,
    Damyan Bogoev
    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