首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >客户端评价

客户端评价
EN

Stack Overflow用户
提问于 2019-06-12 12:59:54
回答 1查看 124关注 0票数 0

我想问一下是什么导致了客户端评估

以前,Image是从数据库加载的,但我将其更改为从Documents获取File,然后在上下文配置中从数据库和关系中删除列,但由于某种原因,它现在在客户端进行计算。

代码语言:javascript
复制
public class DocumentEntry
{
    public Guid Id { get; set; } = Guid.NewGuid();

    public List<File> Documents { get; set; } = new List<File>();

    public File Image => Documents.FirstOrDefault(x => x.Name.EndsWith("jpg"));

    public Author Author { get; set; }
}
代码语言:javascript
复制
public class File
{
    public Guid Id { get; set; } = Guid.NewGuid();

    public Document Document { get; set; }

    public Guid? DocumentId { get; set; }

    public string Name { get; set; }
}
代码语言:javascript
复制
public class Author
{
    public Guid Id { get; set; } = Guid.NewGuid();

    public string FirstName { get; set; }

    public string SecondName { get; set; }
}
代码语言:javascript
复制
var doc = _context
          .DocumentEntry
          .Include(x => x.Documents)
          .Include(x => x.Author)
          .FirstOrDefault(x => x.Documents.Any(c => c.Id == new Guid(id)));
代码语言:javascript
复制
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where {from File c in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Files.File]) where ([c].Id == new Guid(__id_0)) where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =? select [c] => Any()}' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where {from File c in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Files.File]) where ([c].Id == new Guid(__id_0)) where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =? select [c] => Any()}' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Take(1)' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Distinct()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where {from File c in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Files.File]) where ([c].Id == new Guid(__id_0)) where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =? select [c] => Any()}' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([c].Id == new Guid(__id_0))' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =?' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Any()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Take(1)' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'Distinct()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'join AnonymousObject _x in {from DocumentEntry x in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Publikacje.DocumentEntry]) join User x.Author in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Users.User]) on Property([x], "AuthorId") equals Property([x.Author], "Id") into IEnumerable`1 x.Author_group from User x.Author in {[x.Author_group] => DefaultIfEmpty()} where {from File c in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Common.Files.File]) where ([c].Id == new Guid(__id_0)) where  ?= (Convert(Property([x], "Id"), Nullable`1) == Property([c], "DocumentId")) =? select [c] => Any()} orderby EF.Property(?[x]?, "Id") asc select new AnonymousObject(new [] {Convert(EF.Property(?[x]?, "Id"), Object)}) => Take(1) => Distinct()} on Property([x.Documents], "DocumentId") equals Convert([_x].GetValue(0), Nullable`1)' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'orderby [_x].GetValue(0) asc' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'FirstOrDefault()' could not be translated and will be evaluated locally.
EN

Stack Overflow用户

回答已采纳

发布于 2019-06-12 13:03:54

看看是否可以稍微更改LINQ查询。

代码语言:javascript
复制
var guid = new Guid(id);
var doc = _context
          .DocumentEntry
          .Include(x => x.Documents)
          .Include(x => x.Author)
          .FirstOrDefault(x => x.Documents.Any(c => c.Id == guid));
票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56562857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档