Skip to main content

SqlServerStorage

Understands how to store a ServiceStack.MiniProfiler.Profiler to a MSSQL database.

Assembly: ServiceStack.NetFramework.dll
View Source
Declaration
public class SqlServerStorage : DatabaseStorageBase, IStorage

Inherited Properties

ConnectionString

How we connect to the database used to save/load MiniProfiler results.

View Source
Declaration
protected string ConnectionString { get; set; }

Fields

TableCreationScript

Creates needed tables. Run this once on your database.

View Source
Declaration
public const string TableCreationScript = "create table MiniProfilers\r\n  (\r\n     RowId                                integer not null identity constraint PK_MiniProfilers primary key clustered, -- Need a clustered primary key for SQL Azure\r\n     Id                                   uniqueidentifier not null, -- don't cluster on a guid\r\n     Name                                 nvarchar(200) not null,\r\n     Started                              datetime not null,\r\n     MachineName                          nvarchar(100) null,\r\n     [User]                               nvarchar(100) null,\r\n     Level                                tinyint null,\r\n     RootTimingId                         uniqueidentifier null,\r\n     DurationMilliseconds                 decimal(7, 1) not null,\r\n     DurationMillisecondsInSql            decimal(7, 1) null,\r\n     HasSqlTimings                        bit not null,\r\n     HasDuplicateSqlTimings               bit not null,\r\n     HasTrivialTimings                    bit not null,\r\n     HasAllTrivialTimings                 bit not null,\r\n     TrivialDurationThresholdMilliseconds decimal(5, 1) null,\r\n     HasUserViewed                        bit not null,\r\n     Json                                 nvarchar(max)\r\n  );\r\n  -- displaying results selects everything based on the main MiniProfilers.Id column\r\n  create unique nonclustered index IX_MiniProfilers_Id on MiniProfilers (Id);\r\n                \r\n  -- speeds up a query that is called on every .Stop()\r\n  create nonclustered index IX_MiniProfilers_User_HasUserViewed_Includes on MiniProfilers ([User], HasUserViewed) include (Id, [Started]);\r\n"

Methods

Save(MiniProfiler)

Stores <param name="profiler" /> to dbo.MiniProfilers under its Profiler.Id; stores all child Timings and SqlTimings to their respective tables.

View Source
Declaration
public override void Save(MiniProfiler profiler)
Parameters
TypeName
ServiceStack.MiniProfiler.MiniProfilerprofiler

Load(Guid)

Loads the MiniProfiler identifed by 'id' from the database.

View Source
Declaration
public override MiniProfiler Load(Guid id)
Returns

ServiceStack.MiniProfiler.MiniProfiler

Parameters
TypeName
System.Guidid

GetUnviewedIds(String)

Returns a list of Profiler.Ids that haven't been seen by <code data-dev-comment-type="paramref" class="paramref">user</code>.

View Source
Declaration
public override List<Guid> GetUnviewedIds(string user)
Returns

System.Collections.Generic.List<System.Guid>

Parameters
TypeNameDescription
System.StringuserUser identified by the current MiniProfiler.Settings.UserProvider.

|

GetConnection()

Returns a connection to Sql Server.

View Source
Declaration
protected override DbConnection GetConnection()
Returns

System.Data.Common.DbConnection

Inherited Methods

GetConnection()

Returns a DbConnection for your specific provider.

View Source
Declaration
protected abstract DbConnection GetConnection()
Returns

System.Data.Common.DbConnection

GetOpenConnection()

Returns a DbConnection already opened for execution.

View Source
Declaration
protected DbConnection GetOpenConnection()
Returns

System.Data.Common.DbConnection

GetUnviewedIds(String)

Returns a list of ServiceStack.MiniProfiler.MiniProfiler.Ids that haven't been seen by <code data-dev-comment-type="paramref" class="paramref">user</code>.

View Source
Declaration
public abstract List<Guid> GetUnviewedIds(string user)
Returns

System.Collections.Generic.List<System.Guid>

Parameters
TypeNameDescription
System.StringuserUser identified by the current MiniProfiler.Settings.UserProvider.

|

Load(Guid)

Returns the MiniProfiler identified by 'id' from the database or null when no MiniProfiler exists under that 'id'.

View Source
Declaration
public abstract MiniProfiler Load(Guid id)
Returns

ServiceStack.MiniProfiler.MiniProfiler

Parameters
TypeName
System.Guidid

Save(MiniProfiler)

Saves 'profiler' to a database under its ServiceStack.MiniProfiler.MiniProfiler.Id.

View Source
Declaration
public abstract void Save(MiniProfiler profiler)
Parameters
TypeName
ServiceStack.MiniProfiler.MiniProfilerprofiler

Implements