Begins query profiling for a datacontext instance. This overload initiates a unfiltered profiler session without execution plan logging and synchronous log writes to the default output directory. See other overloaded implementations for additional options.
Namespace: Huagati.LinqToSQL.ProfilerAssembly: HuagatiL2SProfiler (in HuagatiL2SProfiler.dll) Version: 1.33.3996.16059
Syntax
C# |
---|
public static QueryProfiler BeginProfiling( this DataContext dc ) |
Visual Basic |
---|
<ExtensionAttribute> _ Public Shared Function BeginProfiling ( _ dc As DataContext _ ) As QueryProfiler |
Visual C++ |
---|
[ExtensionAttribute] public: static QueryProfiler^ BeginProfiling( DataContext^ dc ) |
Parameters
- dc
- Type: System.Data.Linq..::..DataContext
DataContext to profile
Return Value
Returns a QueryProfiler instance representing the current profiler session.Examples
This example shows how to use the DataContext extension method BeginProfiling to set up profiling from within an application.
Alternatively, override the datacontext constructor with a constructor that initialize profiling and a dispose method that terminates profiling:
CopyC#
using (MyDataContext dc = new MyDataContext()) { //initialize profiling - profiler logs will be saved to a local path ([current user's personal directory]\L2SProfiler). QueryProfiler qp = dc.BeginProfiling(); //define a query var query = from emp in dc.Employees where emp.EmployeeAddresses.Address.City == "London" select emp; //enumerate employees foreach (Employee emp in dc.Employees) { System.Diagnostics.Debug.WriteLine(emp.EmployeeID.ToString()); } //disable profiling qp.EndProfiling(); }
CopyC#
public partial class MyDataContext { private QueryProfiler _profiler = null; public MyDataContext(bool enableProfiling) : this() { if (enableProfiling == true) { _profiler = this.BeginProfiling(); } } protected override void Dispose(bool disposing) { if (_profiler != null) { this.EndProfiling(); } base.Dispose(disposing); } }