开发者

Linq to SQL Weird Error

开发者 https://www.devze.com 2023-01-19 16:38 出处:网络
I am getting this error: Could not format node \'Column\' for execution as SQL When I am trying to make any anonymous type:

I am getting this error: Could not format node 'Column' for execution as SQL

When I am trying to make any anonymous type:

 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()
         }
     )
 });

The problem comes when I add a NounTypeId property i开发者_如何学Pythonn the anonymous type.


Might I recommend loading your NounTypes and NounTypeAttributes into local memory, and then shaping?

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
...
0

精彩评论

暂无评论...
验证码 换一张
取 消