반응형
var query2 = (from original in originalDt.AsEnumerable()
join addType in productDt.AsEnumerable() on
original.Field<string>("FACTCD") + original.Field<string>("LINECD") + original["JOBSEQ"] equals
addType.Field<string>("FACTCD") + addType.Field<string>("LINECD") + addType["HANGNO"] into g
from joinType in g.DefaultIfEmpty()
join addType2 in BaseMain.MainDataSet.Tables[0].AsEnumerable() on
original.Field<string>("FACTCD") + original.Field<string>("LINECD") + original.Field<string>("JOBNO") + original.Field<string>("ROUTCD") equals
addType2.Field<string>("FACTCD") + addType2.Field<string>("LINECD") + addType2.Field<string>("RECIPE") + addType2.Field<string>("ROUTCD") into g2
from joinType2 in g2.DefaultIfEmpty()
select new
{
레시피 = original["JOBNO"],
행거번호 = original["JOBSEQ"],
현재볼트 = original["VOLTVAL"],
현재암페어 = original["AMPEVAL"],
현재온도 = original["TEMPVAL"],
// null 값을 체크해준다
제품명 = joinType == null ? string.Empty : joinType["ITEMNM"],
제품수량 = joinType == null ? string.Empty : joinType["QTY"],
투입시간 = joinType == null ? string.Empty : joinType["IN_TIME"],
볼트최소값 = joinType2 == null ? string.Empty : joinType2["VOLTMIN"],
볼트최대값 = joinType2 == null ? string.Empty : joinType2["VOLTMAX"],
암페어최소값 = joinType2 == null ? string.Empty : joinType2["AMPEMIN"],
암페어최대값 = joinType2 == null ? string.Empty : joinType2["AMPEMAX"]
});
결과 뷰
참고 Anonymous Type equals
{
Anonymous Type을 이용한
1 |
from p in persons |
2 |
join w in workers |
3 |
on new { p.FirstName, p.LastName, p.Age} equals new { w.FirstName, w.LastName, w.Age} |
4 |
select ...; |
}
'.NET > LINQ' 카테고리의 다른 글
[.NET] LINQ를 보다 쉽게 작성하기 LINQPad (0) | 2010.02.06 |
---|---|
LINQ 샘플, C# Samples for Visual Studio 2008 (0) | 2009.08.06 |