SELECT

    AxF_GenericList names = AxF_GenericList::newList(Types::String);
    AxF_IEnumerator enumerator;
    str             name;
    ;

    names.add('Batman');
    names.add('Superman');
    names.add('Ironman');

    enumerator = xfrom(name).in(names)
                 .select(name).getEnumerator();

    while (enumerator.moveNext())
    {
         info(enumerator.current());
    }
Produce the following output
Batman
Superman
Ironman

WHERE

    AxF_GenericList names = AxF_GenericList::newList(Types::String);
    AxF_IEnumerator enumerator;
    str             name;
    ;

    names.add('Batman');
    names.add('Superman');
    names.add('Ironman');

    enumerator = xfrom(name).in(names)
                 .where(name == 'Superman')
                 .Select(name).getEnumerator();

    while (enumerator.moveNext())
    {
         info(enumerator.current());
    }
Produce the following output
Superman

ORDER BY

    AxF_GenericList names = AxF_GenericList::newList(Types::String);
    AxF_IEnumerator enumerator;
    str             name;
    ;

    names.add('Batman');
    names.add('Superman');
    names.add('Ironman');

    enumerator = xfrom(name).in(names)
                 .orderBy(name).descending()
                 .select(name).getEnumerator();

    while (enumerator.moveNext())
    {
         info(enumerator.current());
    }
Produce the following output
Superman
Ironman
Batman

GROUP BY

    AxF_GenericList  names = AxF_GenericList::newList(Types::String);
    AxF_IEnumerator  nameEnumerator;
    AxLINQ_IGrouping grpTitle;
    AxF_IEnumerator  grpEnumerator;
    str              name;
    ;

    names.add('Mr Incredible');
    names.add('Mr Anderson');
    names.add('Ms Jupiter');

    grpEnumerator = xfrom(name).in(names)
                    .GroupBy(substr(name, 1, 2)).into(grpTitle)
                    .select(grpTitle).getEnumerator();

    while (grpEnumerator.moveNext())
    {
        grpTitle = grpEnumerator.current();
        info('Group:' + grpTitle.key());
        nameEnumerator = grpTitle.getEnumerator();
        while (nameEnumerator.moveNext())
        {
            info(nameEnumerator.current());
        }
    }
Produce the following output
Group:Mr
Mr Incredible
Mr Anderson
Group:Ms
Ms Jupiter

JOIN

    AxF_IEnumerator         enumerator;
    AxLINQ_TEST_Person      person  = new AxLINQ_TEST_Person('');
    AxF_GenericList         persons = AxF_GenericList::newList(Types::Class);
    AxLINQ_TEST_PhoneCall   phoneCall = new AxLINQ_TEST_PhoneCall('','',datenull(),0);
    AxF_GenericList         phoneCalls = AxF_GenericList::newList(Types::Class);
    AxLINQ_TEST_Phone       phone = new AxLINQ_TEST_Phone('', false);
    AxF_GenericList         phones = AxF_GenericList::newList(Types::Class);
    ;

    phones.add(new AxLINQ_TEST_Phone('11111111', false));
    phones.add(new AxLINQ_TEST_Phone('22222222', true));
    phones.add(new AxLINQ_TEST_Phone('33333333', false));
    phones.add(new AxLINQ_TEST_Phone('44444444', false));

    persons.add(new AxLINQ_TEST_Person('Mowgli'    , '11111111'));
    persons.add(new AxLINQ_TEST_Person('Shere Khan', '22222222'));
    persons.add(new AxLINQ_TEST_Person('Baloo'     , '33333333'));
    persons.add(new AxLINQ_TEST_Person('Bagheera'  , '44444444'));

    phoneCalls.add(new AxLINQ_TEST_PhoneCall('11111111', '22222222', 01\01\2009, 60));
    phoneCalls.add(new AxLINQ_TEST_PhoneCall('22222222', '33333333', 02\01\2009, 100));

    enumerator = xFrom(person).in(persons)
                 .Join(phoneCall).in(phoneCalls)
                   .on(person.phone() == phoneCall.callingPhone())
                 .Join(phone).in(phones)
                    .on(phone.number() == phoneCall.calledPhone())
                 .Select(person.name() + (phone.isMobilePhone() ? ' called mobile' : ' called normal phone')).getEnumerator();

    while (enumerator.moveNext())
    {
        info(enumerator.current());
    }
Produce the following output
Mowgli called mobile
Shere Khan called normal phone

DISTINCT

    AxF_IEnumerator enumerator;
    int             number;
    ;

    enumerator = xfrom(number).in([1, 1, 2, 3, 2])
                 .Select(number).distinct().getEnumerator();

    while (enumerator.moveNext())
    {
        info(enumerator.current());
    }
Produce the following output
1
2
3

Last edited Feb 7, 2010 at 5:49 PM by JesperJensen, version 4

Comments

No comments yet.