Page 1 of 1

Filter (any) statement doesn't work as accpected

Posted: Fri 02 Oct 2009 10:44
by Zero-G.
Hey

I try to use an equivalent to the IN statement, but it doesn't work, as I want.
I have a master table and a related child table. I want to filter the child table with the following code:

Code: Select all

        Dim GetID as new List(of Long)
        GetID.Add(1)
        GetID.Add(2)

        Dim myKundenst = From Query In LinqProvider.GetProvider.Kundenstamms _
                         Where Query.auftrags.Any(Function(c) GetID.Contains(c.Id)) _
                         Select Query
But it doesn't seem to work correct. myKundenst hold all the child's - not filtered.

THX

Posted: Mon 05 Oct 2009 08:46
by AndreyR
You should use the DataLoadOptions.AssociateWith method, like this:

Code: Select all

Dim dlo As New DataLoadOptions
dlo.AssociateWith(Of Kundenstamm)(Function(k As Kundenstamm) (k.Auftrags.Where(Function (a As Auftrag)(GetID.Contains(a.Id)))))
LinqProvider.GetProvider.LoadOptions = dlo 

Posted: Mon 05 Oct 2009 09:48
by Zero-G.
Thanks for the tip
Is it a designed behavior, that DataLoadOptions could not be added, when the DataContext has loaded values before?

THX

Posted: Tue 06 Oct 2009 08:40
by AndreyR
Yes. This behaviour is identical to the one implemented by Microsoft.
This fact is mentioned here:
http://msdn.microsoft.com/en-us/library ... tions.aspx