日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Inside Dynamics Axapta源代码赏析(五)

發布時間:2025/7/14 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Inside Dynamics Axapta源代码赏析(五) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
第十二章 The Database layer
1.更改RecVersion
AX4.0使用了樂觀并發控制,RecVersion是用來標識記錄版本的。
static?void?RecVersionChange(Args?_args)
{
????CustTable?custTableSelected;
????CustTable?custTableSelectedForUpdate;
????CustTable?custTableUpdated;
????;
????ttsbegin;

????select?custTableSelected
????????where?custTableSelected.AccountNum?
==?'4000';

????select?forupdate?custTableSelectedForUpdate
????????where?custTableSelectedForUpdate.AccountNum?
==?'4000';

????select?forupdate?custTableUpdated
????????where?custTableUpdated.AccountNum?
==?'4000';

????
//?At?this?point,?RecVersion?in?all?three?buffers?are?equal.

????custTableUpdated.CreditMax?
=?custTableUpdated.CreditMax;
????custTableUpdated.update();

????print?custTableUpdated.recVersion;
????print?custTableSelectedForupdate.recVersion;
????print?custTableSelected.recVersion;


????
//?At?this?point,?RecVersion?is?changed?in?the?custTableUpdated
????
//?and?custTableSelectedForUpdate?buffers.?CustTableSelected?still
????
//?has?its?original?value?in?RecVersion.

????ttscommit;
????pause;
}

2.跳過ForUpdate和TTSbegin,TTSCommit的檢查.
?CustTable?custTable;
????;
????ttsbegin;
????select?custTable?where?custTable.AccountNum?
==?'4000';
????custTable.CreditMax?
=?1000;

????custTable.skipTTSCheck(
true);
????custTable.update();
????ttscommit;
這樣是可以跳過,但為什么要跳過那?
3.臨時表的使用.
通過setTmp和data兩個方法可以搞定.
static?void?TmpCustTable(Args?_args)
{
????CustTable?custTable;
????CustTable?custTableTmp;
????;
????custTableTmp.setTmp();
????ttsbegin;
????
while?select?custTable
????
{
????????custTableTmp.data(custTable);
????????custTableTmp.doInsert();
????}

????ttscommit;
}

Table有兩個方法,data()和setTmpData(),其中Data()是拷貝一份數據,而setTmpData()只是對象引用的傳遞.
4.臨時表的清空
把臨時表賦值為null的時候,內存被清空,臨時文件被刪除

static?void?TmpLedgerTable(Args?_args)
{
????TmpLedgerTable?tmpLedgerTable;
????;
????tmpLedgerTable.CompanyId?
=?'dat';
????tmpledgerTable.AccountNum?
=?'1000';
????tmpLedgerTable.AccountName?
=?'Name';
????tmpLedgerTable.insert();?
//?Insert?into?first?dataset.

????tmpLedgerTable?
=?null;?//?Allocated?memory?is?freed
???????????????????????????
//?and?file?is?deleted.
????tmpLedgerTable.CompanyId?=?'dat';
????tmpledgerTable.AccountNum?
=?'1000';
????tmpLedgerTable.AccountName?
=?'Name';
????tmpLedgerTable.insert();?
//?Insert?into?new?dataset.
????
????
//Check?it
????while?select?*?from?tmpLedgerTable
????
{
????????print?tmpLedgerTable.AccountName;
?
????}

????pause;
}

5.下面的這段代碼正好印證了前面的說法,setTmpData是指向同一個對象的.

static?void?TmpLedgerTable(Args?_args)
{
????TmpLedgerTable?tmpLedgerTable1;
????TmpLedgerTable?tmpLedgerTable2;
????;
????tmpLedgerTable2.setTmpData(tmpLedgerTable1);

????tmpLedgerTable1.CompanyId?
=?'dat';
????tmpledgerTable1.AccountNum?
=?'1000';
????tmpLedgerTable1.AccountName?
=?'Name';
????tmpLedgerTable1.insert();?
//?Insert?into?shared?dataset.

????tmpLedgerTable2.CompanyId?
=?'dat';
????tmpledgerTable2.AccountNum?
=?'1000';
????tmpLedgerTable2.AccountName?
=?'Name';
????tmpLedgerTable2.insert();?
//?Insert?will?fail?with?dublicate?value.
}

6.ttsabort用于忽略記錄的更改或插入.
剩下的代碼都是一些關于事務和鎖的問題,跟數據庫的理論類似,這里就不摘錄了.


?

轉載于:https://www.cnblogs.com/Farseer1215/archive/2006/09/26/515340.html

總結

以上是生活随笔為你收集整理的Inside Dynamics Axapta源代码赏析(五)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。