This documentation is archived and is not being maintained.

ObjectQuery.ToTraceString Method

Returns the commands to execute against the data source.

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

public string ToTraceString()

Return Value

Type: System.String
A string that represents the commands that the query executes against the data source.

The example in this topic is based on the Adventure Works Sales Model.

using (AdventureWorksEntities advWorksContext =
    new AdventureWorksEntities())
        // Define the object query for the specific product.
        ObjectQuery<Product> productQuery =
            advWorksContext.Product.Where("it.ProductID = 900");

        // Write the store commands for the query.
    catch (EntitySqlException ex)

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5 SP1