dotConnect for Dynamics 365 Documentation
Devart.Data.Dynamics Namespace / DynamicsConnection Class / Clone Method
Example

In This Topic
    Clone Method (DynamicsConnection)
    In This Topic
    Creates a new object that is a copy of the current instance.
    Syntax
    'Declaration
     
    Public Function Clone() As DynamicsConnection
    public DynamicsConnection Clone()

    Return Value

    A new DynamicsConnection object.
    Remarks

    Creates a new DynamicsConnection object with the properties that have the same values as those of the original object. However, changing properties of the new object has no influence on the values of the same properties of the original object.

    Note that state of the new instance is always Closed, regardless of the state of original instance.

    Example
    This example shows how to clone a DynamicsConnection. To make sure all the properties are inherited, one of them (UserId) is written to the console.
    public void CloneAConnection()
    {
      DynamicsConnection dynamicsConnection = new DynamicsConnection(
          "Server=https://your_company.crm4.dynamics.com;User [email protected];Password=A123456789;");
      DynamicsConnection dynamicsConnection2 = (DynamicsConnection)dynamicsConnection.Clone();
      Console.WriteLine(dynamicsConnection2.UserId);
    }
    Public Sub CloneAConnection()
      Dim dynamicsConnection As New DynamicsConnection( _
          "Server=https://your_company.crm4.dynamics.com;User [email protected];Password=A123456789;")
      Dim dynamicsConnection2 As DynamicsConnection = CType(dynamicsConnection.Clone(), DynamicsConnection)
      Console.WriteLine(dynamicsConnection2.UserId)
    End Sub
    See Also