Bug in Executing Nested DBFunctionCall

Posts   
 
    
KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 07-Nov-2006 04:02:53   

<Environment Info> Adpater pattern LLBL Designer version 2.0.0.0 LLBLGen Pro .NET 2.0 ORM Support Classes 2.0.0.60904 .Net 2.0 VS.NET 2005 </Environment Info>

We are using Nested DBFuctionCall , something I like this :

entityFields.DefineField(ADC.SEM.DAL.HelperClasses.GoalPomPlacementMetricFields.SeCost, 1, "Cost", AggregateFunction.Sum);
entityFields.DefineField(ADC.SEM.DAL.HelperClasses.GoalPomPlacementMetricFields.Clicks, 2, AggregateFunction.Sum);
IExpression expCPC = new Expression(entityFields[1], ExOp.Div, entityFields[2]);
entityFields.DefineField(new EntityField2("expCPC", expCPC), 3);
entityFields.DefineField(new EntityField2("CPC", new DbFunctionCall("ROUND", new object[] { new DbFunctionCall("DECODE", new object[] { entityFields[2], 0, 0, entityFields[3] }), 2 })), 4);

And after doing all the required things for DynamicList while making call to FetchTypedList() we are getting "Object not set exception". I debbuged the code and found the problem and fix.

In protected virtual void InsertPersistenceInfoObjects( IDbFunctionCall functionCall ) condition for Parameter == DBFunction is missing(recursive call is missing).

Modified method looks something like this :: <Modified method>

protected virtual void InsertPersistenceInfoObjects( IDbFunctionCall functionCall )
        {
            if(functionCall==null)
            {
                return;
            }
            for( int i = 0; i < functionCall.FunctionParameters.Length; i++ )
            {
                if (functionCall.FunctionParameters[i].GetType() == typeof(DbFunctionCall))
                    InsertPersistenceInfoObjects((IDbFunctionCall)functionCall.FunctionParameters[i]);
                else
                {
                    IEntityField2 parameterAsField = functionCall.FunctionParameters[i] as IEntityField2;
                    if (parameterAsField != null)
                    {
                        functionCall.FieldPersistenceInfos[i] = GetFieldPersistenceInfo(parameterAsField);
                    }
                }
            }
        }

</Modified Method>

Btw after this fix things work for me simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 07-Nov-2006 10:08:40   

Thanks for looking into this! simple_smile . I'll make sure it gets fixed a.s.a.p. simple_smile

(edit) it fails in general with a nested expression as parameter. I'll fix it with a general check for IExpression.

Fixed in next build. You can then do things like:


[Test]
public void NestedDbFunctionCallTest()
{
    ResultsetFields fields = new ResultsetFields(2);
    fields.DefineField(OrderDetailsFields.OrderId, 0);
    fields.DefineField(new EntityField2("Result", new DbFunctionCall("ROUND", 
            new object[] { new DbFunctionCall("ROUND", new object[] { (OrderDetailsFields.UnitPrice * OrderDetailsFields.Quantity), -1 }), -1})), 1);
    DataTable results = new DataTable();
    using(DataAccessAdapter adapter = new DataAccessAdapter())
    {
        adapter.FetchTypedList(fields, results, new RelationPredicateBucket(OrderDetailsFields.OrderId == 10248));
    }

    Assert.AreEqual(results.Rows[0][1], 170.0M);
    Assert.AreEqual(results.Rows[1][1], 100.0M);
    Assert.AreEqual(results.Rows[2][1], 170.0M);
}

if you would want to do that wink

Frans Bouma | Lead developer LLBLGen Pro
KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 07-Nov-2006 15:39:05   

Thanks again for promt action.

Btw when can I get the next release ? I have 3 pending fix (in case you following my threads by my Screen name simple_smile ).

Again I would appreciate if you can send me this particular fix of nested DBFUction and IExpression by mail or something ASAP. My Team has got a release on 15th with that functionality.

Have a great day ahead.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 07-Nov-2006 16:05:28   

We're planning a new build release later today. So within 2 hours tops.

Frans Bouma | Lead developer LLBLGen Pro
KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 07-Nov-2006 18:53:31   

waitin........... simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 07-Nov-2006 19:07:14   

KS wrote:

waitin........... simple_smile

available! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 08-Nov-2006 15:36:24   

Thanks. Couldn't check it as I got another high priority work, however I hope it would be working now simple_smile

KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 20-Nov-2006 23:45:28   

Hey Frans Today I migrated to new LLBL relaease(7-nov). Everything in working fine. Thanks.

Now I need one more favour from you. I need these 3 files generated from new release for Adapter-2005 Preset from you in my email. 1. DataAccessAdapter.cs 2. EntityCollection.cs 3. TypeDefaultValue.cs

now you must be wondering why can't I generate it. It's little tricky to explain, still let me try. We have tweaked the whole Architecture for Generated code to support multiple DBs using same DAL. Object model will be different(as per DB), however it will use same DataAccess layer.

Thanking you in anticipation simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 21-Nov-2006 08:56:29   

KS wrote:

Hey Frans Today I migrated to new LLBL relaease(7-nov). Everything in working fine. Thanks.

Now I need one more favour from you. I need these 3 files generated from new release for Adapter-2005 Preset from you in my email. 1. DataAccessAdapter.cs 2. EntityCollection.cs 3. TypeDefaultValue.cs

now you must be wondering why can't I generate it. It's little tricky to explain, still let me try. We have tweaked the whole Architecture for Generated code to support multiple DBs using same DAL. Object model will be different(as per DB), however it will use same DataAccess layer.

Thanking you in anticipation simple_smile

I don't follow you, sorry. What exactly are you asking?

Frans Bouma | Lead developer LLBLGen Pro
Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 21-Nov-2006 14:22:33   

KS wrote:

Hey Frans Today I migrated to new LLBL relaease(7-nov). Everything in working fine. Thanks.

Now I need one more favour from you. I need these 3 files generated from new release for Adapter-2005 Preset from you in my email. 1. DataAccessAdapter.cs 2. EntityCollection.cs 3. TypeDefaultValue.cs

now you must be wondering why can't I generate it. It's little tricky to explain, still let me try. We have tweaked the whole Architecture for Generated code to support multiple DBs using same DAL. Object model will be different(as per DB), however it will use same DataAccess layer.

Thanking you in anticipation simple_smile

Sorry, but we can't honor requests like this. If you've modified your templates then you are responsible for the outcome. If you really want the previous version of the templates then you can download them from our web site and re-generate using those.

KS
User
Posts: 55
Joined: 08-Aug-2006
# Posted on: 21-Nov-2006 16:37:11   

I was just asking for 1. DataAccessAdapter.cs 2. EntityCollection.cs 3. TypeDefaultValue.cs

generated files for Adapter-2005 preset as I am no more generating these files. However as Chester mentioned "You cannot honor such request", I would changes my Preset and generate them.

Thanks anywz

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 21-Nov-2006 16:42:49   

KS wrote:

I was just asking for 1. DataAccessAdapter.cs 2. EntityCollection.cs 3. TypeDefaultValue.cs

generated files for Adapter-2005 preset as I am no more generating these files. However as Chester mentioned "You cannot honor such request", I would changes my Preset and generate them.

Thanks anywz

Aha ok, it was unclear to me what you wanted simple_smile . Yes, if you want code generated with teh templates shipped, you could copy llblgen pro's install folder to a different folder, install the default templates there and generate code from that designer. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
JMuller
User
Posts: 19
Joined: 09-Mar-2009
# Posted on: 05-Aug-2009 11:53:33   

Hi,

Is there a way to combine a DbFunctionCall with a Expression?

I would like to do something like this:

(TotalPrice - COALESCE(Price1, Price2, Price3)) as Price

Thnx

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Aug-2009 12:10:42