Query single link object

CapableObjects Forums SupportForum Query single link object


This topic contains 3 replies, has 2 voices, and was last updated by  Admin 11 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #5040 Score: 0

    Peter Buchmann

    Please assume following model:
    Class1 1 <——> * Class2

    Class1 has attributes A1 and A2. I would like to query (in PS) all instances of Class2 that have an associated instance of Class1 with several criteria like:

    EcoSpace.PSQuery<Class2>().Where(x => x.Class1.A1 == valueA1 && x.Class1.A2 == valueA2).ToList();

    Ideally this SQL should contain one EXISTS clause that restricts the Class1 table entries but MDriven generates a own clause for each criterium. The MDriven SQL looks inflated but seems to work.

    But I’m just wondering if there is a better way to write such a query so that MDriven can be stimulated to write a shorter query. Any ideas?

    #5041 Score: 0

    Peter Buchmann

    One additon:
    In OCLPS, I would write:
    Class1.AllInstances->Select((A1=valueA1) and (A2=valueA2)).Class2s
    But how can this be written as PSQuery?

    #5042 Score: 0

    Peter Buchmann

    And when I try to write this as PSQuery I end up with:
    PSQuery<CLass1>().Where(x => x.A1 == valueA1 && x.A2 == valueA2).SelectMany(x => x.Class2s).ToList();
    which does not work because SelectMany is not implemented (see also https://www.capableobjects.com/forums/topic/selectmany-in-psquery/).

    Other ideas?

    #5046 Score: 0


    I see your point.
    SelectMany is not implemented in EcoQuery.

    Sidenote; from the testcases you sent I have also implement the Min operator (and also Max and Sum)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.