title: How to consume in process server method with DataSnap 2010
body: <p>I define a server method:</p>
  
  <pre><code>TServerMethod = class(TPersistent)
  public
    function EchoString(Value: string): string;
  end;
  </code></pre>
  
  <p>The method EchoString return an equivalent Value string.</p>
  
  <p>I then use TDSTCPServerTransport with TDSServer and TDSServerClass to wrap the server methods.</p>
  
  <p>In client side, I create a DataSnap TSQLConnection and generate a TServerMethodProxy client class:</p>
  
  <pre><code>function TServerMethodClient.EchoString(Value: string): string;
  begin
    if FEchoStringCommand = nil then
    begin
      FEchoStringCommand := FDBXConnection.CreateCommand;
      FEchoStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
      FEchoStringCommand.Text := 'TServerMethod.EchoString';
      FEchoStringCommand.Prepare;
    end;
    FEchoStringCommand.Parameters[0].Value.SetWideString(Value);
    FEchoStringCommand.ExecuteUpdate;
    Result := FEchoStringCommand.Parameters[1].Value.GetWideString;
  end;
  </code></pre>
  
  <p>I able to consume the EchoString method via TCP connection in client application:</p>
  
  <pre><code>var o: TServerMethodClient;
  begin
    o := TSeverMethodClient.Create(SQLConnection1.DBXConnection);
    try
      ShowMessage(o.EchoString('Hello'));
    finally
      o.Free;
    end;
  end;
  </code></pre>
  
  <p>The above scenarios is using TCP/IP as communication protocol.</p>
  
  <p>However, I wish to deploy my ServerMethod together with my client as "In Process" model. How can I achieve that without changing my client and server method code?</p>
  
  <p>What parameter should I pass to TServerMethodClient.Create constructor in order to establish a in process connection?</p>
  
  <pre><code>o := TSeverMethodClient.Create(SQLConnection1.DBXConnection);
  </code></pre>
  
  <p>In old DataSnap day, we can use TLocalConnection to enjoy In Process access without changing both client and server codes.</p>