filtering objects in relation

From: martin ruff (mruf..imeon.ch)
Date: Mon Dec 02 2002 - 13:52:05 EST

  • Next message: Craig Miskell: "Re: filtering objects in relation"

    Hi,
    I've go the following two tables:
    CREATE TABLE projects(
    id serial NOT NULL PRIMARY KEY,
    name varchar(100) NOT NULL UNIQUE,
    displaybegin date,
    displayend date,);

    and

    CREATE TABLE tasks(
    id serial NOT NULL PRIMARY KEY,
    fk_projectid int4 NOT NULL,
    sortorder numeric,
    displaybegin date,
    displayend date,
    FOREIGN KEY (fk_projectid) REFERENCES projects (id));

    now I want to get all projects in a time range, i.e. all projects that
    are visible today (this works) and for every project its tasks also in a
    given time range:
    I defined a relation from projects to tasks (tasksArray)
    then I have to following expression:
                    Expression begindateexpr = ExpressionFactory. binaryPathExp(
                                             Expression.LESS_THAN_EQUAL_TO,
                                             "displaybegin",
                                             currentdate);
                    Expression enddateexpr = ExpressionFactory. binaryPathExp(
                                             Expression.GREATER_THAN_EQUAL_TO,
                                             "displayend",
                                             currentdate);
                    SelectQuery query = new SelectQuery("Projects",
    begindateexpr.andExp(enddateexpr));
                    query.addOrdering("name", true);
                    projects = theDataContext.performQuery(query);

    this returns me all projects that are visible today, works fine:
    But how can I set the filter for the related tasks?
    the relation taksk is defined as:
            <db-relationship name="tasksArray" source="projects" target="tasks"
    toDependentPK="false" toMany="true">
                    <db-attribute-pair source="ID" target="FK_projectid"/>
            </db-relationship>

    thanks for help
    martin



    This archive was generated by hypermail 2.0.0 : Mon Dec 02 2002 - 13:52:12 EST