Class ProxyDemo.ExpensiveDatabase
- Namespace
- PatternKit.Examples.ProxyDemo
- Assembly
- PatternKit.Examples.dll
Simulates an expensive resource that should be lazily initialized.
public sealed class ProxyDemo.ExpensiveDatabase
- Inheritance
-
ProxyDemo.ExpensiveDatabase
- Inherited Members
- Extension Methods
Remarks
This class represents a heavyweight object (like a database connection) that has expensive initialization costs and should only be created when actually needed.
Constructors
ExpensiveDatabase(string)
Initializes a new instance of the ProxyDemo.ExpensiveDatabase class.
public ExpensiveDatabase(string connectionString)
Parameters
connectionStringstringThe database connection string.
Methods
Query(string)
Executes a SQL query against the database.
public string Query(string sql)
Parameters
sqlstringThe SQL query to execute.
Returns
- string
The query result as a string.