This documentation is archived and is not being maintained.

EntityCommand.ToTraceString Method

Compiles the entity-level command and returns the store command text.

Namespace:  System.Data.EntityClient
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public string ToTraceString()

Return Value

Type: System.String
A string that represents the store command text.

This method is intended for diagnostic use only. Do not make your code dependent on the trace string that this method returns, because the format of the string might change in future releases.

Client-side command compilation consists of the following steps:

  1. Building a command tree from the specified Entity SQL command text if it has not already been built.

  2. Getting the provider factory from the EntityConnection object and using it to create a DbCommandDefinition object. However, if EntityCommand is already associated with a DbCommandDefinition, this step is skipped.

  3. Setting the command tree, parameters, and other settings on the CommonDbCommandDefinition object.

  4. Adding the compiled query plan to the cache, if query plan caching is enabled.

This method does not throw any exceptions of its own. However, it surfaces exceptions that might occur during client-side command compilation.

.NET Framework

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.