Filter (any) statement doesn't work as accpected

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Filter (any) statement doesn't work as accpected

Post by Zero-G. » Fri 02 Oct 2009 10:44

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 05 Oct 2009 08:46

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 

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Mon 05 Oct 2009 09:48

Thanks for the tip
Is it a designed behavior, that DataLoadOptions could not be added, when the DataContext has loaded values before?

THX

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 06 Oct 2009 08:40

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

Post Reply