1
나는 linq을 처음 사용했습니다. 나는 linq을 fill some classes from the database에 사용하고 있습니다.반복 값
내 모든 개체는 하나의 작은 것을 제외하고는 내 linq를 사용하여 올바르게 채워집니다. 아래에서 "SAR" "비행 방향"(행 15,16)에 대해 의 값을 가져야합니다. 오름차순 및 의 값 내림차순의 값을 볼 수 있습니다. 하지만 무엇 "오름차순"에 대한 두 값 개체가 있습니다.
왜 내 값을 반복하지 않습니까? LINQ가 누락 되었습니까?
여기 내 LINQ입니다 : 여기
내 DB 결과입니다 당신은 attRow
에서 Value
을 복용
using (NpgsqlDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
var groups = reader.Cast<System.Data.Common.DbDataRecord>()
.GroupBy(dr => new { ID = (int)dr["id"], AttID = (int)dr["AttId"] })
.GroupBy(g => g.Key.ID);
typeDataList = (
from typeGroup in groups
let typeRow = typeGroup.First().First()
select new TypeData()
{
ID = (int) typeRow["id"],
Type = (string) typeRow["type"],
Attributes =
(
from attGroup in typeGroup
let attRow = attGroup.First()
select new TypeDataAttribute()
{
ID = (int)attRow["AttId"],
Label = (string)attRow["label"],
PossibleValues =
(
from row in attGroup
where !DBNull.Value.Equals(attRow["AttValueId"])
select new TypeDataAttributeValue() { ID = (int)attRow["AttValueId"], Value = (string)attRow["value"] }
).ToArray()
}
).ToArray()
}
);
}
}
정말 고마워요. – capdragon