내 저장소에 해당지도가 있습니다. 서비스에서스칼라 값이 아닌 LinqToSql 그룹에 쿼리로 그룹을 작성하는 방법이 있습니까?
public IQueryable<AwType> GetAwTypes()
{
return from awt in _db.AwTypes
select new AwType
{
Id = awt.Id,
Header = awt.Header,
Description = awt.Description
};
}
public IQueryable<Aw> GetAws()
{
return from aw in _db.Aws
select new Aw
{
Id = aw.Id,
Bw = (from bw in GetBws()
where bw.Id == aw.Bw
select bw
).SingleOrDefault(),
AwType = (from awt in GetAwTypes()
where awt.Id == awAwType
select awt
).SingleOrDefault(),
AwAttribute = aw.AwAttribute
};
}
나는 List<KeyValuePair<AwType, int>>
로 AwType별로 그룹화 신주 인수권 부사채의 수를 싶어. 내가 그 LINQ 쿼리 호출 할 때 는 :
var awGroups = from aw in _repository.GetAws()
group aw by aw.AwType into newGroup
select newGroup;
List<KeyValuePair<AwType, int>> RetGroups = new List<KeyValuePair<AwType, int>>();
foreach (var group in awGroups)
{
RetGroups.Add(new KeyValuePair<AwType, int>(group.Key, group.Count()));
}
return RetGroups;
을 나는 aw.AwType.Id 같은 스칼라 값 그룹에있는 객체에 의해 내가 할 수없는 그룹을 말하는 오류가 발생합니다.
한 번의 호출로 "AwType, int"쌍을 얻을 수있는 방법이 있습니까?
감사 무슨 뜻인지 이해하지 못했다 새로운 {푸, 바 ...}에 의해 그룹 아 당신을 의미합니까, 나는 거의 ... 대답을 기다리고 포기했습니다 :) – spinodal