AssociateWith Question

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

AssociateWith Question

Post by Zero-G. » Wed 02 Mar 2011 11:36

Hey
Using your components: dotConnect for mySQL Version: 6.10.103

I want to create a query, where I get the customers and there offers, which contains some criteria.
Example:
Customer 'Mayer' is related to the offers, and they contain 2 offers for Mayer. In the offers, there is a field called "Auftrag" One row is filled with the values "Glasses" and the other row is filled with the values "Contactlens"
So, I want the customer and by running the query, ONLY the offers row with "Glasses". (Hope you undertand :shock: )

So, I created the following Options and query:

Code: Select all

Dim Auftraege As New List(of String)
Auftraege.Add("Glasses")

Dim dlo As New Devart.Data.Linq.DataLoadOptions
dlo.AssociateWith(Of VOptNeuContext.Kundenstamm)(Function(Ku As VOptNeuContext.Kundenstamm) _
                        Ku.Auftrags.Where(Function(Auf) Auftraege.Contains(Auf.Auftrag1)))

 myDataContext.LoadOptions = dlo

                Dim Kunden = From Kunde In myDataContext.Kundenstamms Join
                             Auftrag In myDataContext.Auftrags On Kunde.Kundenid Equals Auftrag.Kundenid _
                             Where Kunde.Firmenid = LinqProvider.GetAktivCompanyID And _
                             Auftrag.Bewegung = 1 And _
                             Kunde.Geloescht = 0  _
                             Order By Kunde.Nname, Kunde.Vname _
                             Select Kunde Distinct
But when running:

Code: Select all

For Each Kunde In Kunden
   For Each Auftrag in Kunde.Auftrags
      'Here all offers are available - not only these with "Glasses"
  Next
Next
Have you any kind of help for me - PLEASE
HTX

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 02 Mar 2011 15:23

We couldn't reproduce the issue in our environment with the latest 6.10.111 build of dotConnect for MySQL. Please try updating to the latest version and check if the problem persists.

Also, I will send you a test project in a letter. Please specify what should be changed in the sample to reproduce the issue.

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

Post by Zero-G. » Wed 02 Mar 2011 17:46

Hey

I have replied your mail with a modified code example, where it does not work.

THX

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 03 Mar 2011 14:38

Could you please specify the results you are getting with the sample you've sent us? In our environment, this was a single line 'JONES MANAGER', which means that Emps that satisfy the condition on .Hiredate were also filtered by .Job .

When executing the code below, I've received a properly filtered entity set ('JONES MANAGER', 'ALLEN SALESMAN', 'WARD SALESMAN') as well.

Code: Select all

dlo.AssociateWith(Of ScottContext.Dept1) _
    (Function(d As ScottContext.Dept1) _
            d.Emp1s.Where(Function(e As Emp1) e.Hiredate >= BeginDate And e.Hiredate <= EndDate))
...
Dim query = (From d In dc.Dept1s Select d Distinct)
For Each d As Dept1 In query
    For Each em As Emp1 In d.Emp1s
        Console.WriteLine(em.Ename + " " + em.Job)
    Next
Next

Post Reply