-
Notifications
You must be signed in to change notification settings - Fork 30
/
CustomSqlExtensions.cs
20 lines (16 loc) · 1.16 KB
/
CustomSqlExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using LinqToDB;
namespace Lombiq.HelpfulLibraries.LinqToDb.Extensions;
public static class CustomSqlExtensions
{
// You don't need an actual implementation in the function body for these simple expressions. The parameters will be
// used by the attribute.
[Sql.Expression(ProviderName.SqlServer, "JSON_VALUE({0}, {1})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json_extract({0}, {1})", ServerSideOnly = true, InlineParameters = true)]
public static string JsonValue(object expression, string path) => null;
[Sql.Expression(ProviderName.SqlServer, "JSON_MODIFY({0}, {1}, {2})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json_replace({0}, {1}, {2})", ServerSideOnly = true, InlineParameters = true)]
public static string JsonModify(string json, string path, string newValue) => null;
[Sql.Expression(ProviderName.SqlServer, "JSON_QUERY({0})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json({0})", ServerSideOnly = true, InlineParameters = true)]
public static string JsonQuery(string value) => null;
}