Skip to content

Commit 9dd26a0

Browse files
committed
Simpler convert handling.
1 parent 7ede399 commit 9dd26a0

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbConvertTranslator.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@ namespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.I
3030

3131
public class FbConvertTranslator : IMethodCallTranslator
3232
{
33-
static readonly Dictionary<string, string> TypeMappings = new Dictionary<string, string>
33+
static readonly List<string> Mappings = new List<string>
3434
{
35-
[nameof(Convert.ToByte)] = "SMALLINT",
36-
[nameof(Convert.ToDecimal)] = $"DECIMAL({FbTypeMappingSource.DefaultDecimalPrecision},{FbTypeMappingSource.DefaultDecimalScale})",
37-
[nameof(Convert.ToDouble)] = "DOUBLE PRECISION",
38-
[nameof(Convert.ToInt16)] = "SMALLINT",
39-
[nameof(Convert.ToInt32)] = "INTEGER",
40-
[nameof(Convert.ToInt64)] = "BIGINT",
41-
[nameof(Convert.ToString)] = $"VARCHAR({FbTypeMappingSource.VarcharMaxSize})"
35+
nameof(Convert.ToByte),
36+
nameof(Convert.ToDecimal),
37+
nameof(Convert.ToDouble),
38+
nameof(Convert.ToInt16),
39+
nameof(Convert.ToInt32),
40+
nameof(Convert.ToInt64),
41+
nameof(Convert.ToString),
4242
};
4343

4444
static readonly HashSet<Type> SupportedTypes = new HashSet<Type>
45-
{
46-
typeof(bool),
47-
typeof(byte),
48-
typeof(decimal),
49-
typeof(double),
50-
typeof(float),
51-
typeof(int),
52-
typeof(long),
53-
typeof(short),
54-
typeof(string),
55-
typeof(DateTime),
56-
};
45+
{
46+
typeof(bool),
47+
typeof(byte),
48+
typeof(decimal),
49+
typeof(double),
50+
typeof(float),
51+
typeof(int),
52+
typeof(long),
53+
typeof(short),
54+
typeof(string),
55+
typeof(DateTime),
56+
};
5757

5858
static readonly IEnumerable<MethodInfo> SupportedMethods
59-
= TypeMappings.Keys
59+
= Mappings
6060
.SelectMany(t => typeof(Convert).GetTypeInfo().GetDeclaredMethods(t)
6161
.Where(m => m.GetParameters().Length == 1 && SupportedTypes.Contains(m.GetParameters().First().ParameterType)));
6262

0 commit comments

Comments
 (0)