SqlClient CachePath Property Nemiro.Data.dll
The path of storage a cache files. Using only with CacheType = File.

Namespace: Nemiro.Data.Sql
Assembly: Nemiro.Data (in Nemiro.Data.dll) Version: 2.11.4.126 (2.11.4.126)
Syntax

public string CachePath { get; set; }

Property Value

Type: String
Remarks

Use the configuration file for this setting.

<appSettings> 
  <clear /> 
  <!--Cache type--> 
  <add key="NeData:Sql:CacheType" value="File" /> 
  <!--Cache path--> 
  <add key="NeData:Sql:CachePath" value="C:\cache\MyApplication" /> 
</appSettings>

If the specified directory does not exist, it is created automatically.

When using the file cache in projects ASP. NET, ensure that the application and the IIS user have access for write and for modify the contents of a directory CachePath.

Examples

using (SqlClient client = new SqlClient())
{
  client.CacheDuration = 1200; // 20 minutes
  client.CacheType = CachingType.File;
  client.CachePath = @"C:\cache\MyApplication";
  client.CommandText = "SELECT * FROM users";
  var table = client.GetTable();
  Console.WriteLine("Rows: {0}", table.Rows.Count);
  Console.WriteLine("Query execution time: {0}", client.LastQueryTime);
  Console.WriteLine("From cache: {0}", client.LastQueryResultsFromCache);
}
See Also