-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (34 loc) · 1.34 KB
/
Program.cs
File metadata and controls
39 lines (34 loc) · 1.34 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
using Ef_TestPaginationIssueApp.Data;
using Ef_TestPaginationIssueApp.Types;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using var _context = new AppDbContext();
_context.Database.EnsureCreated();
_context.EnsureSeedData();
try
{
var parentDtos = GetParentDtos();
}
catch (Exception ex)
{
throw ex;
}
List<ParentDto> GetParentDtos()
{
IQueryable<ParentDto> parentDto = _context.Parent.Include(x => x.Child)
.Select
(
x => new ParentDto
{
ParentId = x.Id,
SomeValue1 = x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total").Value,
SomeValue2 = x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total2").Value,
CalculatedValue = x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total").Value - x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total2").Value,
CalculatedValue2 = x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total2").Value - x.Child.InfoData.Fields.FirstOrDefault(x => x.Code == "Total").Value,
FullNumber = x.Phone.FullNumber
}
);
var result1 = parentDto.OrderBy(x => x.CalculatedValue2).Skip(25).Take(10);
var result = parentDto.OrderBy(x => x.CalculatedValue2).Skip(25).Take(10).ToList();
return result;
}