简体   繁体   English

LINQ,聚合操作不支持“System.Data.Linq.Binary”类型

[英]The type 'System.Data.Linq.Binary' is not supported in aggregation operations - LINQ

 (from chapter in Chapters
        join userChapter in UserChapters on chapter.Id equals userChapter.ChapterId
        join pub in Publications on chapter.Id equals pub.ChapterId into P 
        from publication in P.DefaultIfEmpty()
        where userChapter.UserId == 9
        group new
                           {
                               PubID = publication.Id,
                               Logo = chapter.Logo
                           } by new { chapter.Id, chapter.Name} into x
                           orderby x.Key.Name
        select new 
       {
           Id = x.Key.Id,
           chapterName = x.Key.Name,
           PublicationCount = x.Count(z => z.PubID > 0),
           Logo = x.Max(z=>z.Logo)
       }
)

In the above query " chapter.Logo " is of type byte[] , when I try to execute this query i am getting following error. 在上面的查询中,“ chapter.Logo ”的类型为byte[] ,当我尝试执行此查询时,我收到以下错误。

The type 'System.Data.Linq.Binary' is not supported in aggregation operations - LINQ. LINQ,聚合操作不支持“System.Data.Linq.Binary”类型。

    (from chapter in Chapters
    join userChapter in UserChapters on chapter.Id equals    userChapter.ChapterId
    join pub in Publications on chapter.Id equals pub.ChapterId into P 
    from publication in P.DefaultIfEmpty()
    where userChapter.UserId == 9
    group new
                       {
                           PubID = publication.Id,
                           Logo = chapter.Logo
                       } by new { chapter.Id, chapter.Name} into x
                       orderby x.Key.Name
    select new 
   {
       Id = x.Key.Id,
       chapterName = x.Key.Name,
       Logo = x.Max(z=>z.Logo.Count())
   }

)

    (from chapter in Chapters
    join userChapter in UserChapters on chapter.Id equals    userChapter.ChapterId
    join pub in Publications on chapter.Id equals pub.ChapterId into P 
    from pub in P.DefaultIfEmpty()
    where userChapter.UserId == 9
    group pub by new { chapter.Id, chapter.Name,chapter.Logo,pub.Id} into x
                       orderby x.Key.Name
    select new 
   {
       Id = x.Key.Id,
       chapterName = x.Key.Name,
       Logo = x.Key.Logo,
   PublicationCount=x.Count()
   }

)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将&#39;byte []&#39;类型转换为&#39;System.Data.Linq.Binary&#39; - How to convert type 'byte[]' to 'System.Data.Linq.Binary' 类型“ System.Data.Linq.Binary”在未引用的程序集中定义 - Type 'System.Data.Linq.Binary' is defined in an assembly that is not referenced 无法在LINQ中将类型&#39;string&#39;隐式转换为&#39;System.Data.Linq.Binary - Cannot implicitly convert type 'string' to 'System.Data.Linq.Binary in LINQ to SQL 无法将&#39;System.Data.Linq.Binary&#39;类型的对象强制转换为&#39;System.Byte []&#39; - Unable to cast object of type 'System.Data.Linq.Binary' to type 'System.Byte[]' 将System.Drawing.Image转换为System.Data.Linq.Binary - Converting System.Drawing.Image to System.Data.Linq.Binary .NET Core中的等效System.Data.Linq.Binary - Equivalent System.Data.Linq.Binary in .net core 如何将内存流转换为System.Data.Linq.Binary? - How to convert Memory Stream to System.Data.Linq.Binary? 如何在C#中将System.Data.Linq.Binary分配为null? - How to assign System.Data.Linq.Binary to null in C#? 类型&#39;&lt;&gt; f__AnonymousType1`2 [System.String,System.Data.Linq.Binary]&#39;必须声明一个默认(无参数)构造函数 - The type '<>f__AnonymousType1`2[System.String,System.Data.Linq.Binary]' must declare a default (parameterless) constructor 无法从“ System.DateTime”转换为“ System.Data.Linq.Binary”错误 - Cannot convert from 'System.DateTime' to 'System.Data.Linq.Binary' error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM