简体   繁体   English

客户端评估

[英]Client side evaluation

I'd to ask what can be causing client side evaluation here 我想问一下什么可以引起客户端评估

Previously Image was being loaded from database, but I changed it to get the File from Documents and then I removed columns from database and relations in context configuration, but for some reason now it evaluates on client side 此前Image正在从数据库中加载,但我改变了它获得File ,从Documents ,然后我删除从数据库中上下文配置关系列,但由于某种原因,现在它的计算结果在客户端

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

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

public class Author
{
    public Guid Id { get; set; } = Guid.NewGuid();

    public string FirstName { get; set; }

    public string SecondName { get; set; }
}

var doc = _context
          .DocumentEntry
          .Include(x => x.Documents)
          .Include(x => x.Author)
          .FirstOrDefault(x => x.Documents.Any(c => c.Id == new Guid(id)));

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.

See if you can change your LINQ query slightly. 看看是否可以稍微更改LINQ查询。

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM