Skip to content

Commit 6dfec76

Browse files
committed
OrderBy("np(NullableInt)")
1 parent c75791d commit 6dfec76

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src-console/ConsoleAppEF2.0/Database/ProductDynamic.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class ProductDynamic
1212
[NotMapped]
1313
public dynamic Properties { get; set; }
1414

15+
public int? NullableInt { get; set; }
16+
1517
public Dictionary<string, object> Dict { get; set; }
1618
}
1719
}

src-console/ConsoleAppEF5/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ static void Main(string[] args)
3737
Console.WriteLine($"orderBy Year DESC = {x.Brand}");
3838
}
3939

40-
Thread.Sleep(500);
40+
var orderByNullableInt = context.Cars.OrderBy("np(NullableInt)").ToList();
41+
foreach (var x in orderByNullableInt)
42+
{
43+
Console.WriteLine($"orderBy NullableInt = {x.Brand} {x.NullableInt}");
44+
}
4145

4246
context = new TestContext();
4347
var orderBy3 = context.Cars.OrderBy("3 DESC").ToList();

src-console/ConsoleAppEF5_InMemory/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ static void Main(string[] args)
1515
{
1616
using (var context = new TestContextEF5())
1717
{
18-
context.Products.Add(new ProductDynamic { Dict = new Dictionary<string, object> { { "Name", "test" } } });
18+
context.Products.Add(new ProductDynamic { NullableInt = 1, Dict = new Dictionary<string, object> { { "Name", "test" } } });
19+
context.Products.Add(new ProductDynamic { NullableInt = null, Dict = new Dictionary<string, object> { { "Name2", "test2" } } });
1920
context.SaveChanges();
2021
}
2122

@@ -28,6 +29,12 @@ static void Main(string[] args)
2829
{
2930
Console.WriteLine(result.Key + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
3031
}
32+
33+
var orderedResults = context.Products.OrderBy("np(NullableInt)");
34+
foreach (var result in orderedResults)
35+
{
36+
Console.WriteLine(result.Key + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
37+
}
3138
}
3239
}
3340
}

0 commit comments

Comments
 (0)