Could not translate expression into SQL and could not treat it as a local expression

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Could not translate expression into SQL and could not treat it as a local expression



I'm creating a function in WCF that brings me an SP and I pass it through parameters two integers, but when I try to save or execute it sends me this error:



Could not translate expression 'value(DataAccessName).spInsPerfilArea(1, 4)' into SQL and could not treat it as a local expression.



Any idea?



Store Procedure:


ALTER PROCEDURE [DB].[spInsPerfilArea]
@PerfilId Int,
@AreaId Int
--@FechaCreacion DateTime,
--@FechaUltimaModificacion DateTime = null

AS
BEGIN
SET NOCOUNT ON
IF EXISTS(SELECT 1 FROM DB.TableName WHERE PerfilId =@PerfilId AND AreaId = @AreaId)
BEGIN
RETURN 0;
END

ELSE

BEGIN

INSERT INTO DB.TableName (PerfilId, AreaId, FechaCreacion,FechaUltimaModificacion)
VALUES(@PerfilId,@AreaId,GETDATE(),GETDATE())

END

SET NOCOUNT OFF

END



Function:


public static GuardarPerfilAreaRes GuardarPerfilArea(GuardarPerfilAreaReq req)
{
var res = new GuardarPerfilAreaRes();
try
{
using (var contexto = DataAccessDefaultDataContext.GetDataContext(Instancia.Mex))
foreach (var idSelPerfil in req.PerfilArea.PerfilId)
{
var perfilArea = contexto.spInsPerfilArea(idSelPerfil, req.PerfilArea.AreaId);
//perfilArea
}

}
catch (Exception ex)
{
res.EstatusOperacion = new EstatusOperacion()
{
Exitoso = false,
Mensaje = ex.Message
};
}
return res;

}



Class:


public class PerfilArea
{

[DataMember(Name = "PerfilId", IsRequired = true, Order =0)]
public int PerfilId { get; set; }

[DataMember(Name = "AreaId", IsRequired = true, Order = 1)]
public int AreaId { get; set; }

}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP