From 5943bb72cbb47e76da38c4d335f9beb3b3a76887 Mon Sep 17 00:00:00 2001 From: John GEFFERS Date: Wed, 13 Sep 2023 12:12:43 -0400 Subject: [PATCH] Added missing datatypes to GetDefaultColumnDefinitionsForType --- Castle.DynamicLinqQueryBuilder.Tests/Rules/Tests.cs | 11 +++++++++-- Castle.DynamicLinqQueryBuilder/ColumnBuilder.cs | 11 +++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Castle.DynamicLinqQueryBuilder.Tests/Rules/Tests.cs b/Castle.DynamicLinqQueryBuilder.Tests/Rules/Tests.cs index 9e849b3..993aa6f 100644 --- a/Castle.DynamicLinqQueryBuilder.Tests/Rules/Tests.cs +++ b/Castle.DynamicLinqQueryBuilder.Tests/Rules/Tests.cs @@ -4187,11 +4187,18 @@ public class ColumnBuilderTestClass { public int Age { get; set; } public int? FavoriteNumber { get; set; } + public long NumberOfShoes { get; set; } + public long? NumberOfSocks { get; set; } public string Name { get; set; } public DateTime Birthday { get; set; } public DateTime? FavoriteBirthday { get; set; } public double DollarsInWallet { get; set; } public double? DesiredDollarsInWallet { get; set; } + public float DollarsInSavings { get; set; } + public float? DesiredDollarsInSavings { get; set; } + public decimal DollarsInRetirement { get; set; } + public decimal? DesiredDollarsInRetirement { get; set; } + #pragma warning disable IDE1006 // Naming Styles public string camelCaseField { get; set; } #pragma warning restore IDE1006 // Naming Styles @@ -4207,11 +4214,11 @@ public void ColumnBuilderTest() { var result = typeof(ColumnBuilderTestClass).GetDefaultColumnDefinitionsForType(); - Assert.IsTrue(result.Count == 10); + Assert.IsTrue(result.Count == 16); result = typeof(ColumnBuilderTestClass).GetDefaultColumnDefinitionsForType(true); - Assert.IsTrue(result.Count == 10); + Assert.IsTrue(result.Count == 16); } diff --git a/Castle.DynamicLinqQueryBuilder/ColumnBuilder.cs b/Castle.DynamicLinqQueryBuilder/ColumnBuilder.cs index 41d1feb..db6ea7e 100644 --- a/Castle.DynamicLinqQueryBuilder/ColumnBuilder.cs +++ b/Castle.DynamicLinqQueryBuilder/ColumnBuilder.cs @@ -24,7 +24,7 @@ public static List GetDefaultColumnDefinitionsForType(this Typ var id = 1; foreach (var prop in dataType.GetProperties()) { - if (prop.GetCustomAttribute(typeof (IgnoreDataMemberAttribute)) != null) continue; + if (prop.GetCustomAttribute(typeof(IgnoreDataMemberAttribute)) != null) continue; var name = camelCase ? prop.Name.ToCamelCase() : prop.Name; @@ -32,11 +32,14 @@ public static List GetDefaultColumnDefinitionsForType(this Typ var type = string.Empty; - if ((prop.PropertyType == typeof (double)) || (prop.PropertyType == typeof (double?))) + if ((prop.PropertyType == typeof(double)) || (prop.PropertyType == typeof(double?)) + || (prop.PropertyType == typeof(float)) || (prop.PropertyType == typeof(float?)) + || (prop.PropertyType == typeof(decimal)) || (prop.PropertyType == typeof(decimal?))) { type = "double"; } - else if ((prop.PropertyType == typeof (int)) || (prop.PropertyType == typeof (int?))) + else if ((prop.PropertyType == typeof(int)) || (prop.PropertyType == typeof(int?)) + || (prop.PropertyType == typeof(long)) || (prop.PropertyType == typeof(long?))) { type = "integer"; } @@ -90,7 +93,7 @@ public static List GetDefaultColumnDefinitionsForType(this Typ Type = type, Id = id.ToString() }); - break; + break; case "boolean": itemBankColumnDefinitions.Add(new ColumnDefinition() {