AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.07.2008, 00:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
axStart: Using base enums in your .net connector
Источник: http://axstart.spaces.live.com/Blog/...C0A0!363.entry
==============


When using Dynamics AX base enums  in  C#,  the created code gets a little bit ugly. We have to use the base enum values (integer)  instead of the element name.  This approach belongs, to my opinion to the ‘BAD’ practices.
A clean solution is creating the base enums in C#. A baseenum ABC  with elements None,A,B,C would look like this in C#, I have added underscore in the C# code because the baseEnum can contain reserved words.
Public enum _ABC {_None = 0,_A, _B, _C}
From this point we can fake the base enum behavior in C#. Example set Blocked field on the Customer table
Public enum_CustVendorBlocked {_No = 0 , _Invoice = 1 , _All = 2}
 
Public void test()
{
     AxaptaRecord custTable;
    _CustVendorBlocked blocked;
 
   //BAD practice    
    custTable.setField("Blocked",1);
    //BAD practice    
 
    //BEST practice

    custTable.setField("Blocked",(System.Int32)_CustVendorBlocked._Invoice);
    blocked = (_CustVendorBlocked) AxCustTable.getField(("Blocked");
    //BEST practice

}
 
It is also possible to place all baseEnums in an aditional namespace. You could generate this namespace from AX


namespace BaseEnums
{
    public enum _NoYes { _no =0 , _yes}
    public enum  _ABC {_None = 0 , _A = 1 , _B = 2 , _C = 3}
    public enum  _ABCModel {_Revenue = 0 , _ContributionMargin = 1 , _Value = 2 , _Link = 3}
    public enum _AcceptReject {_Reject = 0 , _Accept = 1}
    public enum  _AccountChoice {_Account = 0 , _Selection = 1}
    public enum  _AccountOffsetaccount {_Account = 0 , _OffsetAccount = 1}
    public enum  _AccountOrder {_None = 0 , _Account = 1 , _Order = 2 , _Auto = 3}
ETC ….
ETC …

Источник: http://axstart.spaces.live.com/Blog/...C0A0!363.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Arijit Basu: DAX 4.01 .NET Business Connector: Microsoft.Dynamics.BusinessConnectorNet Blog bot DAX Blogs 3 30.09.2008 01:17
axStart: A structure way off dealing with garbage collection & memory leaks with the Dynamics AX .net connector. Blog bot DAX Blogs 0 31.07.2008 22:05
axStart: Test script for your .Net Connector Blog bot DAX Blogs 0 18.01.2008 16:30
Inside Dynamics AX 4.0: Working with the .NET Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
ALEG: Проект "Фишка недели" и первый пост - Microsoft Dynamics™ AX .NET Business Connector Blog bot DAX Blogs 1 22.11.2006 09:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:46.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.