11.11 系统中的数据字典定义是什么,如何使用?

数据字典在系统中的作用是维护一些常用的词语,同时记录用户的习惯用语,使系统在使用过程中自动完善自己,比如:自然人信息中需要记录自然人的民族,中国有56个民族,但由于地区分布的不同,某个地区主要就只有哪几个民族,这样避免了把所有56个民族都列出来,数据太多用户反而很难取得有用的信息。

 

           所在组件:IBeamMDAACommon.dll

名称空间:IBeam.MDAA.ORMObjects (数据库实体)

IBeam.MDAA.Objects (业务对象)

用法举例:

 

在当事人Party保存时保存民族:

string _Category = "民族";

if ( !string.IsNullOrEmpty(party.Nationality) && !DALDictionaries.Exists(party.OwnerID, _Category, party.Nationality) )

{

    DALDictionaries dictionaries = new DALDictionaries();

    dictionaries.Category = _Category;

    dictionaries.DataType = "string";

    dictionaries.SortIndex = (int)DALDictionaries.FindCountByCategory(party.OwnerID, _Category) + 1;

    dictionaries.Phrase = party.Nationality;

    dictionaries.OwnerID = party.OwnerID;

     dictionaries.Save();

 }

 

       在编辑界面中使用数据字典:

DictionaryList dictionaryList = DictionaryList.GetDictionaryList("民族");

foreach (var item in dictionaryList)

{

    if (!cmbNationality.Items.Contains(item.Phrase))

    {

       cmbNationality.Items.Add(item.Phrase);

    }

}

原文地址:https://www.cnblogs.com/yyj/p/2209934.html