Begins query profiling for a datacontext instance. This overload expose all configurable parameters supported by the profiler.
Namespace: Huagati.LinqToSQL.ProfilerAssembly: HuagatiL2SProfiler (in HuagatiL2SProfiler.dll) Version: 1.33.3996.16059
Syntax
C# |
---|
public static QueryProfiler BeginProfiling( this DataContext dc, string outputPath, ProfilerFilter filter, ExecutionPlanMode executionPlanMode, bool asyncLogging ) |
Visual Basic |
---|
<ExtensionAttribute> _ Public Shared Function BeginProfiling ( _ dc As DataContext, _ outputPath As String, _ filter As ProfilerFilter, _ executionPlanMode As ExecutionPlanMode, _ asyncLogging As Boolean _ ) As QueryProfiler |
Visual C++ |
---|
[ExtensionAttribute] public: static QueryProfiler^ BeginProfiling( DataContext^ dc, String^ outputPath, ProfilerFilter^ filter, ExecutionPlanMode executionPlanMode, bool asyncLogging ) |
Parameters
- dc
- Type: System.Data.Linq..::..DataContext
DataContext to profile
- outputPath
- Type: System..::..String
Output path or URL to the profiler query log.
- filter
- Type: Huagati.LinqToSQL.Profiler.Filters..::..ProfilerFilter
An instance of a ProfilerFilter used to filter what queries/executions to include in the log.
- executionPlanMode
- Type: Huagati.LinqToSQL.Profiler..::..ExecutionPlanMode
ExecutionPlanMode value controlling whether execution plans should be retrieved or not. See the ExecutionPlanMode enum documentation for available options.
- asyncLogging
- Type: System..::..Boolean
Controls whether log writes should be synchronous (false, default) or asynchronous (true).
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 with a page read filter set to 10k page reads. // Also include actual execution plans for queries that exceed this filter setting, and use asynchronous log writing mode. QueryProfiler qp = dc.BeginProfiling(@"c:\temp\profilerOutput", new PageReadFilter(10000), ExecutionPlanMode.Actual, true); //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) { string profilerOutput = @"https://apps.huagati.com/queryprofiler/?logid=7382"; _profiler = this.BeginProfiling(profilerOutput, new ExecutionTimeFilter(500), ExecutionPlanMode.Actual, true); } } protected override void Dispose(bool disposing) { if (_profiler != null) { this.EndProfiling(); } base.Dispose(disposing); } }