Skip to content

Commit 95fadb1

Browse files
committed
Add sql server data provider project.
1 parent 7c07d30 commit 95fadb1

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Serilog.Ui.Core;
3+
using System;
4+
5+
namespace Serilog.Ui.MsSqlServerProvider
6+
{
7+
public static class DataProviderOptionBuilderExtensions
8+
{
9+
public static void UseSqlServer(
10+
this DataProviderOptionBuilder optionsBuilder,
11+
string connectionString,
12+
string tableName,
13+
string schemaName = null
14+
)
15+
{
16+
if (string.IsNullOrEmpty(connectionString))
17+
throw new ArgumentNullException(nameof(connectionString));
18+
19+
if (string.IsNullOrEmpty(tableName))
20+
throw new ArgumentNullException(nameof(tableName));
21+
22+
var relationProvider = new RelationalDbOptions
23+
{
24+
ConnectionString = connectionString,
25+
TableName = tableName,
26+
Schema = schemaName
27+
};
28+
29+
optionsBuilder.Services.AddSingleton(relationProvider);
30+
}
31+
}
32+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\Serilog.Ui.Core\Serilog.Ui.Core.csproj" />
9+
</ItemGroup>
10+
11+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Serilog.Ui.Core;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
namespace Serilog.Ui.MsSqlServerProvider
6+
{
7+
public class SqlServerDataProvider : IDataProvider
8+
{
9+
private readonly SqlServerOptions _options;
10+
11+
public SqlServerDataProvider(SqlServerOptions options)
12+
{
13+
_options = options;
14+
}
15+
16+
public Task<(IEnumerable<LogModel>, int)> FetchDataAsync(int page, int count)
17+
{
18+
throw new System.NotImplementedException();
19+
}
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Serilog.Ui.MsSqlServerProvider
2+
{
3+
public class SqlServerOptions
4+
{
5+
public string ConnectionString { get; set; }
6+
7+
public string TableName { get; set; }
8+
9+
public string SchemaName { get; set; } = "dbo";
10+
}
11+
}

0 commit comments

Comments
 (0)