Begins query profiling for a datacontext instance. This overload allows a ProfilerFilter (from the Huagati.LinqToSQL.Profiler.Filters namespace) to be specified. Execution plans are disabled when using this overload.
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 ) |
Visual Basic |
---|
<ExtensionAttribute> _ Public Shared Function BeginProfiling ( _ dc As DataContext, _ outputPath As String, _ filter As ProfilerFilter _ ) As QueryProfiler |
Visual C++ |
---|
[ExtensionAttribute] public: static QueryProfiler^ BeginProfiling( DataContext^ dc, String^ outputPath, ProfilerFilter^ filter ) |
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.
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. See filter documentation for additional filter options QueryProfiler qp = dc.BeginProfiling(@"c:\temp\profilerOutput", new PageReadFilter(10000)); //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)); } } protected override void Dispose(bool disposing) { if (_profiler != null) { this.EndProfiling(); } base.Dispose(disposing); } }