forked from zzzprojects/System.Linq.Dynamic.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (36 loc) · 1.5 KB
/
Program.cs
File metadata and controls
41 lines (36 loc) · 1.5 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text.Json;
using ConsoleAppEF2.Database;
namespace ConsoleApp_net5_0_EF5_InMemory
{
static class Program
{
private readonly static JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
static void Main(string[] args)
{
using (var context = new TestContextEF5())
{
context.Products.Add(new ProductDynamic { NullableInt = 1, Dict = new Dictionary<string, object> { { "Name", "test" } } });
context.Products.Add(new ProductDynamic { NullableInt = null, Dict = new Dictionary<string, object> { { "Name2", "test2" } } });
context.SaveChanges();
}
using (var context = new TestContextEF5())
{
var results = context.Products.Where("Dict.Name == @0", "test");
Console.WriteLine("results = ?");
foreach (var result in results)
{
Console.WriteLine(result.Key + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
}
var orderedResults = context.Products.OrderBy("np(NullableInt)");
foreach (var result in orderedResults)
{
Console.WriteLine(result.Key + JsonSerializer.Serialize(result.Dict, JsonSerializerOptions));
}
}
}
}
}