Note that there are some explanatory texts on larger screens.

plurals
  1. POExplicit construction of entity type '###' in query is not allowed.
    primarykey
    data
    text
    <p>Using Linq commands and Linq To SQL datacontext, Im trying to instance an Entity called "Produccion" from my datacontext in this way: </p> <pre><code>Demo.View.Data.PRODUCCION pocoProduccion = ( from m in db.MEDICOXPROMOTORs join a in db.ATENCIONs on m.cmp equals a.cmp join e in db.EXAMENXATENCIONs on a.numeroatencion equals e.numeroatencion join c in db.CITAs on e.numerocita equals c.numerocita where e.codigo == codigoExamenxAtencion select new Demo.View.Data.PRODUCCION { cmp = a.cmp, bonificacion = comi, valorventa = precioEstudio, codigoestudio = lblCodigoEstudio.Content.ToString(), codigopaciente = Convert.ToInt32(lblCodigoPaciente.Content.ToString()), codigoproduccion = Convert.ToInt32(lblNroInforme.Content.ToString()), codigopromotor = m.codigopromotor, fecha = Convert.ToDateTime(DateTime.Today.ToShortDateString()), numeroinforme = Convert.ToInt32(lblNroInforme.Content.ToString()), revisado = false, codigozona = (c.codigozona.Value == null ? Convert.ToInt32(c.codigozona) : 0), codigoclinica = Convert.ToInt32(c.codigoclinica), codigoclase = e.codigoclase, } ).FirstOrDefault(); </code></pre> <p>While executing the above code, I'm getting the following error that the stack trace is included: </p> <pre><code>System.NotSupportedException was caught Message="The explicit construction of the entity type 'Demo.View.Data.PRODUCCION' in a query is not allowed." Source="System.Data.Linq" StackTrace: en System.Data.Linq.SqlClient.QueryConverter.VisitMemberInit(MemberInitExpression init) en System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node) en System.Data.Linq.SqlClient.QueryConverter.Visit(Expression node) en System.Data.Linq.SqlClient.QueryConverter.VisitSelect(Expression sequence, LambdaExpression selector) en System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc) en System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc) en System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node) en System.Data.Linq.SqlClient.QueryConverter.Visit(Expression node) en System.Data.Linq.SqlClient.QueryConverter.VisitFirst(Expression sequence, LambdaExpression lambda, Boolean isFirst) en System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc) en System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc) en System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node) en System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node) en System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations) en System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) en System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression) en System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) en Demo.View.InformeMedico.realizarProduccionInforme(Int32 codigoExamenxAtencion, Double precioEstudio, Int32 comi) en D:\cs_InformeMedico\app\InformeMedico.xaml.cs:línea 602 en Demo.View.InformeMedico.UpdateEstadoEstudio(Int32 codigo, Char state) en D:\cs_InformeMedico\app\InformeMedico.xaml.cs:línea 591 en Demo.View.InformeMedico.btnGuardar_Click(Object sender, RoutedEventArgs e) en D:\cs_InformeMedico\app\InformeMedico.xaml.cs:línea 683 InnerException: </code></pre> <p>Is that now allowed in LINQ2SQL?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload