Erro de Servidor no Aplicativo '/'.

The entity or complex type 'DatabaseEntity.Foto' cannot be constructed in a LINQ to Entities query.

Descrição: Ocorreu uma exceção sem tratamento durante a execução da atual solicitação da Web. Examine o rastreamento de pilha para obter mais informações sobre o erro e onde foi originado no código.

Detalhes da Exceção: System.NotSupportedException: The entity or complex type 'DatabaseEntity.Foto' cannot be constructed in a LINQ to Entities query.

Erro de Origem:


Linha 59:                     fotos = fotos.Where(o => o.Evento.Id == IdEvento);
Linha 60: 
Linha 61:                 Fotos = fotos != null && fotos.Any()
Linha 62:                     ? fotos.Select(o => new DatabaseEntity.Foto
Linha 63:                     {

Arquivo de Origem: d:\web\localuser\pornomassacre\www\Fotos.aspx.cs    Linha: 61

Rastreamento de Pilha:


[NotSupportedException: The entity or complex type 'DatabaseEntity.Foto' cannot be constructed in a LINQ to Entities query.]
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.CheckInitializerType(Type type) +171
   System.Data.Entity.Core.Objects.ELinq.MemberInitTranslator.TypedTranslate(ExpressionConverter parent, MemberInitExpression linq) +90
   System.Data.Entity.Core.Objects.ELinq.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq) +49
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +106
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input) +89
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding& binding) +69
   System.Data.Entity.Core.Objects.ELinq.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda) +80
   System.Data.Entity.Core.Objects.ELinq.SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) +36
   System.Data.Entity.Core.Objects.ELinq.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod) +13
   System.Data.Entity.Core.Objects.ELinq.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) +101
   System.Data.Entity.Core.Objects.ELinq.TypedTranslator`1.Translate(ExpressionConverter parent, Expression linq) +49
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) +106
   System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert() +17
   System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +256
   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__6() +39
   System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +288
   System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +154
   System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Func`1 operation) +9
   System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +279
   System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +11
   System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() +45
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +186
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +61
   PaginaFotos.ListarFotos() in d:\web\localuser\pornomassacre\www\Fotos.aspx.cs:61
   PaginaFotos.Page_Load(Object sender, EventArgs e) in d:\web\localuser\pornomassacre\www\Fotos.aspx.cs:80
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


Informações sobre a Versão: Microsoft .NET Framework Versão:4.0.30319; Versão do ASP.NET:4.8.4700.0