-
Notifications
You must be signed in to change notification settings - Fork 935
/
Copy pathNameGenerator.cs
43 lines (41 loc) · 1.08 KB
/
NameGenerator.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
41
42
43
using System;
using System.Text;
using NHibernate.Engine;
using NHibernate.Type;
using NHibernate.Util;
namespace NHibernate.Hql
{
/// <summary>
/// Provides utility methods for generating HQL / SQL names.
/// Shared by both the 'classic' and 'new' query translators.
/// </summary>
public class NameGenerator
{
// Since v5.4
[Obsolete("This method has no more usage in NHibernate and will be removed in a future version.")]
public static string[][] GenerateColumnNames(IType[] types, ISessionFactoryImplementor f)
{
string[][] columnNames = new string[types.Length][];
for (int i = 0; i < types.Length; i++)
{
int span = types[i] != null ? types[i].GetColumnSpan(f) : 1;
columnNames[i] = new string[span];
for (int j = 0; j < span; j++)
{
columnNames[i][j] = ScalarName(i, j);
}
}
return columnNames;
}
public static string ScalarName(int x, int y)
{
return new StringBuilder(16)
.Append("col_")
.Append(x)
.Append(StringHelper.Underscore)
.Append(y)
.Append(StringHelper.Underscore)
.ToString();
}
}
}