-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnowflakeCommand.IsDistinct.cs
33 lines (29 loc) · 1.1 KB
/
SnowflakeCommand.IsDistinct.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//-----------------------------------------------------------------------
// <copyright file="SnowflakeCommand.IsDistinct.cs" company="Jonas Schubert">
// Copyright (c) Jonas Schubert. All rights reserved.
// </copyright>
// <author>Jonas Schubert</author>
//-----------------------------------------------------------------------
namespace Snowflake.Data.Xt;
/// <summary>
/// The snowflake command.
/// </summary>
/// <typeparam name="T">The generic type. This is used to parse properties for the query.</typeparam>
public partial class SnowflakeCommand<T>
where T : class
{
/// <summary>
/// Ensures a distinct query.
/// </summary>
/// <returns>The snowflake command.</returns>
/// <exception cref="InvalidOperationException">Command already marked as distinct.</exception>
public SnowflakeCommand<T> IsDistinct()
{
if (this.Sql.Contains("SELECT DISTINCT", StringComparison.Ordinal))
{
throw new InvalidOperationException("Command is already marked as distinct!");
}
this.SqlBuilder.Replace("SELECT", "SELECT DISTINCT");
return this;
}
}