FetchTypedList wrong SQL

Posts   
 
    
YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 20-Aug-2009 10:51:24   

The following code : const string alias = "RowTotal";

            ResultsetFields fields = new ResultsetFields(1);
            fields.DefineField(new EntityField2(alias, (TagWrkCreditDebetFields.BdKplg + TagWrkCreditDebetFields.BdKplgAdm)), 0);
            DataTable results = new DataTable();

            IRelationPredicateBucket bucket = new RelationPredicateBucket();
            bucket.PredicateExpression.Add(TagWrkCreditDebetFields.Id == 23366912);

            using (DataAccessAdapter adapter = new DataAccessAdapter())
                adapter.FetchTypedList(fields, results, bucket);

Generates the following query with oracle :

    Query: SELECT "TAG_WRK_CREDIT_DEBET"."BD_KPLG" + "TAG_WRK_CREDIT_DEBET".

"BD_KPLG_ADM" AS "RowTotal" FROM DUAL WHERE ( ( "TAG_WRK_CREDIT_DEBET"."ID" = :I d1)) Parameter: :Id1 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: I nput. Value: 23366912.

The DUAL key word should be replaced by the table name (TAG_WRK_CREDIT_DEBET).

Any idea ?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 20-Aug-2009 12:37:31   

Instead of using a new EntityField2, use a field of TagWrkCreditDebetFields e.g. TagWrkCreditDebetFields.Id and set its ExpressionToApply to the needed expression.

Since a new EntityField2 doesn't have PersistenceInfo, thus the Framework doesn't know which table to use.