質問編集履歴
2
改善点
title
CHANGED
File without changes
|
body
CHANGED
@@ -61,4 +61,60 @@
|
|
61
61
|
distinctはそのまま使うと重複条件が多いためまた引数に何を書いてよいか分からず(x => x.EntryIdと書いてもオーバロードが違うのかうまくいかず)か、うまく重複削除してあげたいものを削除してくれません。
|
62
62
|
また結合条件を書くことに関しましては、クエリ式のサンプルが少なく’selectionIdの最大値の一つを取得する’といった結合条件の書き方が分かりません。
|
63
63
|
どのように対処すればよいでしょうか?
|
64
|
-
よろしくお願い致します。
|
64
|
+
よろしくお願い致します。
|
65
|
+
|
66
|
+
# 追記分
|
67
|
+
|
68
|
+
```
|
69
|
+
int PageNumber = candidateFilterList.pageNumber * candidateFilterList.pageSize - candidateFilterList.pageSize ?? 0;
|
70
|
+
int PageSize = candidateFilterList.pageSize ?? 20;
|
71
|
+
|
72
|
+
/*追加分*/
|
73
|
+
var selectiontable = (from o in _base.phoenixDB.t_selection
|
74
|
+
group o by o.EntryId into g
|
75
|
+
orderby g.Key descending
|
76
|
+
from item in g
|
77
|
+
where item.EntryId == g.Max(x => x.EntryId)
|
78
|
+
select item).Skip(PageNumber).Take(PageSize);
|
79
|
+
|
80
|
+
//viewで仕様する全てのデータを取得
|
81
|
+
var fulltables = (from entry in _base.phoenixDB.t_entry
|
82
|
+
join selection in selectiontable /*selectiontableをjoin*/ on entry.EntryId equals selection.EntryId
|
83
|
+
join phases in _base.phoenixDB.m_phase on selection.PhaseId equals phases.PhaseId
|
84
|
+
join jobcategories in _base.phoenixDB.m_jobcategory on entry.JobCategoryId equals jobcategories.JobCategoryId
|
85
|
+
join selectionstatuses in _base.phoenixDB.m_selection_status on entry.SelectionStatusId equals selectionstatuses.SelectionStatusId
|
86
|
+
join entryroutes in _base.phoenixDB.m_entry_route on entry.EntryRouteId equals entryroutes.EntryRouteId
|
87
|
+
join locations in _base.phoenixDB.m_location on entry.LocationId equals locations.LocationId
|
88
|
+
join interviewers in _base.phoenixDB.t_interviewer on selection.SelectionId equals interviewers.SelectionId into tInteviewers
|
89
|
+
orderby entry.EntryId descending
|
90
|
+
select new BaseEntry
|
91
|
+
{
|
92
|
+
candidateid = entry.EntryId,
|
93
|
+
candidatename = entry.CandidateName,
|
94
|
+
candidatenamekana = entry.CandidateNameKana,
|
95
|
+
locationIds = (int)entry.LocationId,
|
96
|
+
location = locations.LocationName,
|
97
|
+
jobcategory = jobcategories.JobCategoryName,
|
98
|
+
jobcateoryid = entry.JobCategoryId,
|
99
|
+
entryroute = entryroutes.EntryRouteName,
|
100
|
+
entryrouteid = entry.EntryRouteId,
|
101
|
+
attribute = entry.IsFresher,
|
102
|
+
phase = phases.PhaseName,
|
103
|
+
phaseid = selection.PhaseId,
|
104
|
+
selectionstatus = selectionstatuses.SelectionStatusName,
|
105
|
+
selectuonstatusids = entry.SelectionStatusId,
|
106
|
+
selectionlimit = selection.SelectionLimit,
|
107
|
+
expectedjoinsdate = entry.JoinExpectedDate,
|
108
|
+
department = entry.DepartmentName,
|
109
|
+
adoptcost = entry.AdoptCost,
|
110
|
+
adoptrecordmonth = entry.AdoptCostRecordMonth,
|
111
|
+
adoptpaymentmonth = entry.AdoptCostPaymentMonth,
|
112
|
+
createdate = entry.CreatedDate,
|
113
|
+
checkweather = tInteviewers.OrderByDescending(x => x.InterviewerId).Where(x => x.SelectionId == selection.SelectionId && x.UserId == userId).Count()
|
114
|
+
}).ToList();
|
115
|
+
|
116
|
+
|
117
|
+
/*
|
118
|
+
Result => skipはメソッド 'Skip' は、LINQ to Entities では並べ替え済みの入力に対してのみサポートされます
|
119
|
+
*/
|
120
|
+
```
|
1
文言修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
createdate = entry.CreatedDate,
|
45
45
|
checkweather = tInteviewers.OrderByDescending(x => x.InterviewerId).Where(x => x.SelectionId == selection.SelectionId && x.UserId == userId).Count()
|
46
46
|
})
|
47
|
-
/*.Distinct()を使いたい*/.Skip(PageNumber).Take(PageSize).ToList();
|
47
|
+
/*.Distinct(x => x.Entry_Id)を使いたい*/.Skip(PageNumber).Take(PageSize).ToList();
|
48
48
|
```
|
49
49
|
|
50
50
|
本題なのですがこの結合テーブルはクエリ式を用いてjoinを行っております。
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
そこで上記のコードから重複削除を行うdistinct、もしくは
|
60
60
|
`join selection in DB.t_selection on entry.EntryId equals selection.EntryId`部分に一意の値である’SelectionIdの最大値だけを結合する’結合条件を書き、結合させたいのですが、
|
61
|
-
distinctはそのまま使うと重複条件が多いためまた引数に何を書いてよいか分からず(x => x.
|
61
|
+
distinctはそのまま使うと重複条件が多いためまた引数に何を書いてよいか分からず(x => x.EntryIdと書いてもオーバロードが違うのかうまくいかず)か、うまく重複削除してあげたいものを削除してくれません。
|
62
62
|
また結合条件を書くことに関しましては、クエリ式のサンプルが少なく’selectionIdの最大値の一つを取得する’といった結合条件の書き方が分かりません。
|
63
63
|
どのように対処すればよいでしょうか?
|
64
64
|
よろしくお願い致します。
|