C# 客户端评估
我想问一下,是什么导致了客户端的评估 以前从数据库加载C# 客户端评估,c#,asp.net-core,entity-framework-core,C#,Asp.net Core,Entity Framework Core,我想问一下,是什么导致了客户端的评估 以前从数据库加载图像,但我将其更改为从文档中获取文件,然后从数据库中删除列和上下文配置中的关系,但由于某些原因,现在它在客户端进行计算 public class DocumentEntry { public Guid Id { get; set; } = Guid.NewGuid(); public List<File> Documents { get; set; } = new List<File>();
图像
,但我将其更改为从文档
中获取文件
,然后从数据库中删除列和上下文配置中的关系,但由于某些原因,现在它在客户端进行计算
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; }
}
看看是否可以稍微更改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));
看看是否可以稍微更改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));
无法根据现有代码再现您的问题。从提供的错误消息来看,错误似乎发生在
c=>c.Id==newguid(Id)
中。您是否检查了错误消息的详细信息?您最好能共享一个可复制的演示。@XueliChenc=>c.Id==new Guid(Id)
问题在于无法基于现有代码复制您的问题。从提供的错误消息来看,错误似乎发生在c=>c.Id==newguid(Id)
中。您是否检查了错误消息的详细信息?您最好能共享一个可复制的演示。@XueliChenc=>c.Id==newguid(Id)
是问题所在
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.
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));