The SqlTopicRepository
provides an implementation of the ITopicRepository
interface for use with Microsoft SQL Server. All requests are sent directly to the database, with no effort to first retrieve the data from, or subsequently store the data in, a local cache.
Note: The schema for the Microsoft SQL Server implementation can be found at
OnTopic.Data.Sql.Database
. It is not currently distributed as part of theSqlTopicRepository
and must be deployed separately.
Installation can be performed by providing a <PackageReference /
> to the OnTopic.Data.Sql
NuGet package.
<Project Sdk="Microsoft.NET.Sdk.Web">
…
<ItemGroup>
<PackageReference Include="OnTopic.Data.Sql" Version="5.0.0" />
</ItemGroup>
</Project>
var sqlTopicRepository = new SqlTopicRepository(connectionString);
var rootTopic = sqlTopicRepository.Load();
Note: In real-world applications, it is recommended that the
SqlTopicRepository
be wrapped by theCachedTopicRepository
, which provides an in-memory cache of anyITopicRepository
implementation.