Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

InitContactList

以下のメソッドでは、データベース内のすべての Contact インスタンスのオブジェクト ID を入力値として使用して、ContactList プロパティを初期化します。このメソッドでは、Provider.Contact ByName クエリを使用してこの処理を実行します。このメソッドは、以下を実行します。

  1. ByName から返される CacheCommand を取得します。ただし、開いている CacheConnection インスタンスは ByName に渡す必要があります。

  2. クエリの入力パラメータとして使用する新しい CacheParameter オブジェクトを作成します。このメソッドは、パラメータの値として NULL を割り当てます。NULL をパラメータの入力値として渡すと、すべての Contact インスタンスが一致するようになります。

  3. このパラメータを CacheCommand オブジェクトに追加します。

  4. CacheCommand オブジェクトの ExecuteReader メソッドを呼び出して、ByName を実行します。

  5. ExecuteReader から返される CacheReader オブジェクトの結果に繰り返し処理を行い、そのデータを ContactList に格納します。

完成したメソッドは以下のとおりです。このメソッドの本文を、PhoneFormObj.csInitContactList スタブに追加します。


private void InitContactList()
{
  CacheCommand command = Contact.ByName(cnCache);
  CacheParameter name_param = new CacheParameter("Name", CacheDbType.NVarChar);
  name_param.Value = null;
  command.Parameters.Add(name_param);
  CacheDataReader reader = command.ExecuteReader();
  while (reader.Read())
  {
    string id = reader[reader.GetOrdinal("ID")].ToString();
    ContactList.Add(id); 
   }
  reader.Close(); 
 }

Note:

CacheCommandCacheDataReader の使用方法の詳細は、"第 III 章 : Caché Managed Provider : リレーショナル・インタフェース" を参照してください。

FeedbackOpens in a new tab