[2.0] CONVERT via dbfunctioncall issue

Posts   
 
    
Xavier
User
Posts: 7
Joined: 20-Jun-2007
# Posted on: 01-Jul-2009 12:00:09   

Hi,

I have a problem when trying to convert a bit into an int when fetching a dynamic list.

My field is defined as follow:

 fields.DefineField(MyTableFields.MyIntCol, 1,AggregateFunction.Sum);
fields[1].ExpressionToApply =  new DbFunctionCall("Convert(INT,{0})", new object[] { MyTableFields.MyIntCol});

The generated sql doesn't looks like this:


SUM(Convert(INT,{0})([dbo].[MyTable].[MyIntCol])) AS [MyIntCol] 

I would have expect the {0} to be replaced by dbo].[MyTable].[MyIntCol]. Obviously this code doesn't work.

Your help will be much appreciated.

cheers,

Xav

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Jul-2009 14:27:21   

Which LLBLGen Pro runtime library version are you using?

Would you please try the following instead:

fields.DefineField(MyTableFields.MyIntCol, 1);
fields[1].ExpressionToApply = new DbFunctionCall("SUM(Convert(INT,{0}))", new object[] {MyTableFields.MyIntCol});
Xavier
User
Posts: 7
Joined: 20-Jun-2007
# Posted on: 01-Jul-2009 15:54:42   

Hi,

Thanks but I already tried that and it doesn't work cry


SUM(Convert(INT,{0}))([dbo].[MyTable].[MyIntCol]) AS [MyIntCol] 

For the version : see thread header => 2.0.0.0

Any other thoughts?

Cheers

Xav

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Jul-2009 16:03:00   

Constants in DBFunctionCalls was not yet supported in v.2.0 If possible please port your code to v2.6, won't take long toport your code, and it's free upgrade.

Btw, check the following thread to know how to get the runtime library version (for future usage): http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722