Unofficial Content
  • This documentation is valid for:

To get the data stores from a KB, make sure to add the Artech.Genexus.Common.dll reference to your project and define the following:

using Artech.Genexus.Common.ModelParts;
using Artech.Genexus.Common.Entities;

Use the Get Method from the Working model to return the Data store list.

DataStoresPart dss = kb.DesignModel.Environment.TargetModel.Parts.Get<DataStoresPart>();

You can iterate the list to get detailed information:

foreach (GxDataStore ds in dss.DataStores)
{
    Console.WriteLine(string.Format("Datastore {0} default?{1} DBMS:{2}", ds.DataStoreCategory.Name, ds.DataStoreCategory.IsDefault,ds.Dbms));
} 

Advanced Sample:

using System.Collections.Generic; 
using System.Text; 
using System.Windows.Forms; 
using Artech.Architecture.Common.Objects; 
using Artech.Packages.Genexus.Common.Entities; 
using Artech.Packages.Genexus.Common.ModelParts; 
namespace Foo {
	public class Bar { 
		public static void ProcessDataStores() { 
			ProcessDataStores(KnowledgeBase.KB.DesignModel); 
			ProcessDataStores(KnowledgeBase.KB.WorkingModel); 
		} 
		public static void ProcessDataStores(KBModel kbModel) { 
			GxModel gxModel = kbModel.GetAs<gxmodel>(); 
			StringBuilder builder = new StringBuilder(); 
			foreach (GxDataStore dataStore in gxModel.DataStores) 
			{ 
				string line = string.Format("{0}: {1}({2})", 
				dataStore.DataStoreCategory.Name, 
				dataStore.Description, 
				dataStore.Dbms); 
				builder.AppendLine(line); 
			} 
			string caption = string.Format("DataStores of '{0}' model", kbModel.Name); 
			MessageBox.Show(builder.ToString(), caption); 
		}
	}
}

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant