Показать сообщение отдельно
Старый 18.06.2009, 15:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: Trap typecast
Источник: http://www.axaptapedia.com/Trap_typecast
==============

Summary: caution trap in implicit typecast int64 to boolean

== Typecast from int64(RecId) to boolean ==
(tested in DynamicsAX 2009)

the implicit typecast from int/int64 to boolean is often used in ax sources...

select * from table where table.field == blabla
if (table.recid)


public boolean exist( EDT _value)
{
return (select * from table where table.field == _value).recId;
}


BUT.....

when the RecId (as 64bit integer) last 8 bits are 0
the typecast results in a false even though the RecId is not 0

so, take a look at the bestpractice (design patterns for table exist method)

'''when you'll need a boolean, than use a boolean expression !!!'''

if (table.RecId != 0)












[[category:caution trap]]


Источник: http://www.axaptapedia.com/Trap_typecast
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.