Skip to content

Commit 51c0263

Browse files
committed
orderByNullableDateTimeResult
1 parent 77234d4 commit 51c0263

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src-console/ConsoleAppEF3.1/Program.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static void Main(string[] args)
1010
{
1111
var context = new TestContext();
1212

13-
// context.Database.EnsureDeleted();
13+
//context.Database.EnsureDeleted();
1414
context.Database.EnsureCreated();
1515

1616
var dateDeleted = new DateTime(2019, 2, 2);
@@ -21,12 +21,19 @@ static void Main(string[] args)
2121
context.Cars.Add(new Car { Brand = "Ford", Color = "Blue", Vin = "yes", Year = "2017", DateLastModified = dateLastModified, DateDeleted = dateDeleted });
2222
context.Cars.Add(new Car { Brand = "Fiat", Color = "Red", Vin = "yes", Year = "2016", DateLastModified = dateLastModified.AddDays(1) });
2323
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "no", Year = "1979", DateLastModified = dateLastModified.AddDays(2) });
24-
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "a%bc", Year = "1979", DateLastModified = dateLastModified.AddDays(3) }); ;
24+
context.Cars.Add(new Car { Brand = "Alfa", Color = "Black", Vin = "a%bc", Year = "1979", DateLastModified = dateLastModified.AddDays(3), DateDeleted = dateDeleted.AddDays(1) }); ;
2525
context.SaveChanges();
2626
}
2727

2828
var selectNullableDateTime = context.Cars.FirstOrDefault(c => c.DateDeleted == dateDeleted);
29-
Console.WriteLine(selectNullableDateTime.Key);
29+
Console.WriteLine($"selectNullableDateTime.Key = {selectNullableDateTime.Key}");
30+
31+
var orderByNullableDateTimeResult = context.Cars.OrderBy(c => c.DateDeleted);
32+
foreach (var x in orderByNullableDateTimeResult)
33+
{
34+
Console.WriteLine($"orderByNullableDateTimeResult.Key,DateDeleted = {x.Key},{x.DateDeleted}");
35+
}
36+
3037
}
3138
}
3239
}

0 commit comments

Comments
 (0)