Edit

Share via


SqlPersistenceProviderFactory Constructors

Definition

Initializes a new instance of the SqlPersistenceProviderFactory class.

Overloads

SqlPersistenceProviderFactory(NameValueCollection)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified parameter collection.

SqlPersistenceProviderFactory(String)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string.

SqlPersistenceProviderFactory(String, Boolean)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string and serializeAsText parameters.

SqlPersistenceProviderFactory(String, Boolean, TimeSpan)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string, serializeAsText, and lockTimeout parameters.

Remarks

Overloads of the constructor for the SqlPersistenceProviderFactory class provide parameters for setting the following:

  • The connection string used for accessing the SQL database.

  • The lock time-out used for defining lock ownership duration.

  • Whether the persistence data is serialized as XML or binary data.

SqlPersistenceProviderFactory(NameValueCollection)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified parameter collection.

public:
 SqlPersistenceProviderFactory(System::Collections::Specialized::NameValueCollection ^ parameters);
public SqlPersistenceProviderFactory (System.Collections.Specialized.NameValueCollection parameters);
new System.ServiceModel.Persistence.SqlPersistenceProviderFactory : System.Collections.Specialized.NameValueCollection -> System.ServiceModel.Persistence.SqlPersistenceProviderFactory
Public Sub New (parameters As NameValueCollection)

Parameters

parameters
NameValueCollection

The collection of parameters used by the new persistence provider factory. Valid parameters include lockTimeout, connectionStringName, and serializeAsText.

Examples

The following code example shows how to create a new instance of the SqlPersistenceProviderFactory class using a parameters collection.

NameValueCollection parameters = new NameValueCollection();
parameters.Add("connectionStringName", DataBaseConstants.ConnectionString);
parameters.Add("lockTimeout", "00:01:00");
parameters.Add("serializeAsText", "false");

SqlPersistenceProviderFactory factory = new SqlPersistenceProviderFactory(
    parameters);

Remarks

This constructor can be used to arbitrarily specify lockTimeout, connectionString, and serializeAsText without specifying the other parameters as required by the other constructors (for example, to specify the connectionString and lockTimeout parameters without specifying the serializeAsText parameter.)

Applies to

SqlPersistenceProviderFactory(String)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string.

public:
 SqlPersistenceProviderFactory(System::String ^ connectionString);
public SqlPersistenceProviderFactory (string connectionString);
new System.ServiceModel.Persistence.SqlPersistenceProviderFactory : string -> System.ServiceModel.Persistence.SqlPersistenceProviderFactory
Public Sub New (connectionString As String)

Parameters

connectionString
String

The connection parameters for the new persistence provider instance.

Examples

The following code example shows how to create a new instance of the SqlPersistenceProviderFactory class using a connection string.

SqlPersistenceProviderFactory factory = new SqlPersistenceProviderFactory(
     DataBaseConstants.ConnectionString);

Applies to

SqlPersistenceProviderFactory(String, Boolean)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string and serializeAsText parameters.

public:
 SqlPersistenceProviderFactory(System::String ^ connectionString, bool serializeAsText);
public SqlPersistenceProviderFactory (string connectionString, bool serializeAsText);
new System.ServiceModel.Persistence.SqlPersistenceProviderFactory : string * bool -> System.ServiceModel.Persistence.SqlPersistenceProviderFactory
Public Sub New (connectionString As String, serializeAsText As Boolean)

Parameters

connectionString
String

The connection parameters for the new persistence provider instance.

serializeAsText
Boolean

Specifies whether data is serialized as text rather than binary.

Examples

The following code example shows how to create a new instance of the SqlPersistenceProviderFactory class.

SqlPersistenceProviderFactory factory = new SqlPersistenceProviderFactory(
    DataBaseConstants.ConnectionString,
    false);

Remarks

The default value for serializeAsText is false, which indicates that persistence information is serialized as binary data.

Applies to

SqlPersistenceProviderFactory(String, Boolean, TimeSpan)

Initializes a new instance of the SqlPersistenceProviderFactory class, configured with the specified connection string, serializeAsText, and lockTimeout parameters.

public:
 SqlPersistenceProviderFactory(System::String ^ connectionString, bool serializeAsText, TimeSpan lockTimeout);
public SqlPersistenceProviderFactory (string connectionString, bool serializeAsText, TimeSpan lockTimeout);
new System.ServiceModel.Persistence.SqlPersistenceProviderFactory : string * bool * TimeSpan -> System.ServiceModel.Persistence.SqlPersistenceProviderFactory
Public Sub New (connectionString As String, serializeAsText As Boolean, lockTimeout As TimeSpan)

Parameters

connectionString
String

The connection parameters for the new persistence provider factory instance.

serializeAsText
Boolean

Specifies whether data is serialized as text rather than binary.

lockTimeout
TimeSpan

The time-out for lock ownership. Locked instances are automatically unlocked after this time period. A time-out of TimeSpan.Zero specifies that no locking is used.

Examples

The following code example shows how to create a new instance of the SqlPersistenceProviderFactory class.

SqlPersistenceProviderFactory factory = new SqlPersistenceProviderFactory(
    DataBaseConstants.ConnectionString,
    false,
    TimeSpan.FromSeconds(60));

Remarks

The default value for serializeAsText is false, which indicates that persistence information is serialized as binary data.

The default value for lockTimeout is TimeSpan.Zero, which indicates that locking is not used. If TimeSpan.MaxValue is used, then locks are maintained indefinitely.

Applies to