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

Filter on collections

3 Answers 86 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.
Madhu
Top achievements
Rank 1
Madhu asked on 15 Feb 2011, 08:41 PM

 

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

3 Answers, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 17 Feb 2011, 06:40 PM
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
0
Madhu
Top achievements
Rank 1
answered on 17 Apr 2011, 04:55 PM
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
0
Damyan Bogoev
Telerik team
answered on 18 Apr 2011, 03:26 PM
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
Tags
LINQ (LINQ specific questions)
Asked by
Madhu
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Madhu
Top achievements
Rank 1
Share this question
or