Repository.Model.GetModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
Line 12: Line 12:


== Usage Example ==
== Usage Example ==
<div style="margin-right: 150px;">
{{APIComment|Declare a new repository connection class.}}
{{APIComment|Declare a new repository connection class.}}
         Private WithEvents MyRepository As New Repository
         Private WithEvents MyRepository As New Repository
Line 26: Line 27:
         Dim AModel as cModel
         Dim AModel as cModel
         AModel = MyRepository.GetModel(ListOfModels(0).ID)
         AModel = MyRepository.GetModel(ListOfModels(0).ID)
</div>

Revision as of 21:43, 23 May 2014


Returns the model from the current project with the specified ID. Returns nothing if the model does not exist or is not in the current project.


Note regarding compound analytical models: After you connect to a database and create the cModel using Repository Class (GetModel or GetAllModels methods), the Repository Class must stay connected to the same database until you are done working with the model.

Syntax

  • GetModel( IDAs Integer)AscModel

Parameters

ID: The ID of the model to retrieve.

Usage Example

Declare a new repository connection class.

       Private WithEvents MyRepository As New Repository

Connect to the Synthesis repository.

       Dim Success As Boolean = False
       Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")

Get the list of Models in the connected repository.

       Dim ListOfModels() As NameIdPair
       ListOfModels = MyRepository.GetAllModelsInfo()

Select the ID of the model and retrieve it. In this example, the first model is used.

       Dim AModel as cModel
       AModel = MyRepository.GetModel(ListOfModels(0).ID)