Linq to SQL странная ошибка - PullRequest
       2

Linq to SQL странная ошибка

2 голосов
/ 08 октября 2010

Я получаю эту ошибку: Could not format node 'Column' for execution as SQL

Когда я пытаюсь создать анонимный тип:

 select new
 {
     NounTypeName = nt.Name,
     Attributes =
     (
         from a in nt.NounTypeAttributes
         group a by a.Attribute into g
         select new { 
             NounTypeId = nt.NounTypeId, 
             Key = g.Key + " (" + g.Count() + ")", 
             NounTypeAttributeId = 
                 (from i in g select i.NounTypeAttributeId)
                  .Take(1).SingleOrDefault(), Count = g.Count()
         }
     )
 });

Проблема возникает, когда я добавляю свойство NounTypeId ванонимный тип.

1 Ответ

1 голос
/ 08 октября 2010

Могу ли я порекомендовать загрузить ваши NounTypes и NounTypeAttributes в локальную память, а затем формировать?

CustomDataContext myDC = new CustomDataContext();
DataLoadOptions myOptions = new DataLoadOptions();
myOptions.LoadWith<NounType>(nt => nt.NounTypeAttributes);
myDC.LoadOptions = myOptions;

List<NounType> theNounTypes =
(
  from nt in myDC.NounTypes
  where //TODO filterExpression
  select nt
).ToList();

var queryResult = from nt in theNounTypes
  select new
...
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...