Skip to content

Commit 5a58293

Browse files
Eoin Motherwaycincuranet
Eoin Motherway
authored andcommitted
IsFirebird extensions method
1 parent d875d5b commit 5a58293

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
6+
namespace FirebirdSql.EntityFrameworkCore.Firebird.Extensions
7+
{
8+
using System;
9+
10+
/// <summary>
11+
/// FirebirdSQL specific extension methods for <see cref="DatabaseFacade"/>.
12+
/// </summary>
13+
public static class FbDatabaseFacadeExtensions
14+
{
15+
/// <summary>
16+
/// <para>
17+
/// Returns true if the database provider currently in use is the FirebirdSQL provider.
18+
/// </para>
19+
/// <para>
20+
/// This method can only be used after the <see cref="DbContext" /> has been configured because
21+
/// it is only then that the provider is known. This means that this method cannot be used
22+
/// in <see cref="DbContext.OnConfiguring" /> because this is where application code sets the
23+
/// provider to use as part of configuring the context.
24+
/// </para>
25+
/// </summary>
26+
/// <param name="database">
27+
/// The facade from <see cref="DbContext.Database" />.
28+
/// </param>
29+
/// <returns>
30+
/// True if FirebirdSQL is being used; false otherwise.
31+
/// </returns>
32+
public static bool IsFirebird(this DatabaseFacade database)
33+
=> database.ProviderName.Equals(typeof(FbOptionsExtension).GetTypeInfo().Assembly.GetName().Name, StringComparison.Ordinal);
34+
}
35+
}

0 commit comments

Comments
 (0)