我正在做这样的查询:
加入
public IEnumerable<ProblemsViewModel_Base> GetProblemsSearchClassification(string searchTerm)
{
var subjectProblems =
from p in aux_problem
join sub in Subject on p.aux_ClassificationID.Id equals sub.Id
where sub.Title.Contains(searchTerm)
orderby p.CreatedOn descending
select new ProblemsViewModel_Base
{
aux_CustomID = p.aux_CustomID
,
Id = p.aux_problemId.Value
,
title = p.aux_name
,
CreatedOn = p.CreatedOn.Value
};
return subjectProblems;
}
并且没有加入
public IEnumerable<ProblemsViewModel_Base> GetProblemsSearchDetails(string searchTerm){
var detailsProblems = aux_problem
.Where(p => p.aux_CustomID.Contains(searchTerm))
.OrderByDescending(c => c.CreatedOn)
.Select(i => new ProblemsViewModel_Base
{
aux_CustomID = i.aux_CustomID
,
Id = i.aux_problemId.Value
,
title = i.aux_name
,
CreatedOn = i.CreatedOn.Value
});
return detailsProblems;}
经过三个查询,我加入并获得了不同的结果:
var joinedResults = detailsResults.Union(requestorResults).Union(classificationResults);
var distinctResults = joinedResults.GroupBy(p => p.Id).Select(p => p.First())
我的问题出现在结果中我使用第二个查询(没有连接的那个)进行联合时,结果没有排序,但是如果我避免这个查询,使用 Joins 进行所有查询的联合,结果是有序的。
这可能是这里的问题?谢谢!