2
나는 C# .Net 웹 응용 프로그램을 보유하고 있으며 다음 LINQ 쿼리를 사용하여 사용자가 만들었거나 여러 사용자 역할을 가진 제안 목록을 구별합니다. 반환 할 목록에는 연합 및 고유 한 후에도 동일한 제안서의 속임수가 포함됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?LINQ 연합 및 고유
var thereturn = FindAll(DetachedCriteria.For<Proposal>(),
new Order("CreateDate", false));
//get the proposals that aUser created
IList<Proposal> it =
thereturn.Where(proposal => proposal.CreatedBy.Equals(aUser)).ToList();
//get the proposals that aUser is a BOE Author
IList<Proposal> it2 =
thereturn.Where(proposal =>
proposal.BOEs.Any(boe =>
boe.Users.Where(a => a.Name == aUser).Any())).ToList();
//get all other proposals that aUser is on
IList<Proposal> it3 =
thereturn.Where(proposal =>
proposal.Users.Where(o => o.Name == aUser).Any()).ToList();
//now union with all other proposals that aUser is on
return it3.Union(it).Union(it2).
OrderByDescending(o=>o.CreateDate).Distinct().ToList();
@sinelaw .... 사용자 지정 같음 연산자가 없습니다. Hmmmmm – MikeTWebb
MikeTWebb : 사용자 정의 동등 연산자가 없다는 것은 아마 비교가 참조됨을 의미합니다. 중복 된 자료가 있다는 것을 어떻게 알 수 있습니까? BTW, 어디에서'thereturn' 열거 형을 가져 옵니까? 또 다른 문제는 그것이 처음부터 중복을 포함하고있는 것일 수 있습니다. – sinelaw
@sinelaw .... thereturn은 모든 제안 목록이며 모두 기본 키에 대한 Guid가 있습니다. 위의 코드를 추가했습니다. 뒤집은 것이 중복되지 않습니다. – MikeTWebb