forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQLFunctionTemplateWithRequiredParameters.cs
40 lines (36 loc) · 1.14 KB
/
SQLFunctionTemplateWithRequiredParameters.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
34
35
36
37
38
39
40
using System.Collections;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using NHibernate.Engine;
using NHibernate.SqlCommand;
using NHibernate.Type;
using System;
namespace NHibernate.Dialect.Function
{
/// <summary>
/// A template-based SQL function which substitutes required missing parameters with defaults.
/// </summary>
[Serializable]
public class SQLFunctionTemplateWithRequiredParameters : SQLFunctionTemplate
{
private readonly object[] _requiredArgs;
public SQLFunctionTemplateWithRequiredParameters(IType type, string template, object[] requiredArgs) : base(type, template)
{
_requiredArgs = requiredArgs;
}
public SQLFunctionTemplateWithRequiredParameters(IType type, string template, object[] requiredArgs, bool hasParenthesesIfNoArgs) : base(type, template, hasParenthesesIfNoArgs)
{
_requiredArgs = requiredArgs;
}
public override SqlString Render(IList args, ISessionFactoryImplementor factory)
{
var combinedArgs =
args.Cast<object>()
.Concat(_requiredArgs.Skip(args.Count))
.ToArray();
return base.Render(combinedArgs, factory);
}
}
}