简体   繁体   English

实体框架过程不起作用

[英]Entity Framework procedure is not working

When I run this code and watch in SQL Server Profiler, there is no return value 当我运行此代码并在SQL Server Profiler中观察时,没有返回值

exec [dbo].[p_PersonelEkleAgiGetir] 
     @MedeniDurum = N'Evli',
     @CocukSayisi = 0,
     @EsCalismaDurumu = N'Çalışmıyor'

I erased the N from in front of the parameters and then it works. 我从参数前面删除了N ,然后它起作用了。 What do I have to do for this to work in the code? 我需要做什么才能使其在代码中起作用?

This is my entity procedure code 这是我的实体过程代码

public virtual ObjectResult<Nullable<decimal>> p_PersonelEkleAgiGetir(string medeniDurum, Nullable<int> cocukSayisi, string esCalismaDurumu)
{
    var medeniDurumParameter = medeniDurum != null ?
        new ObjectParameter("MedeniDurum", medeniDurum) :
        new ObjectParameter("MedeniDurum", typeof(string));

    var cocukSayisiParameter = cocukSayisi.HasValue ?
        new ObjectParameter("CocukSayisi", cocukSayisi) :
        new ObjectParameter("CocukSayisi", typeof(int));

    var esCalismaDurumuParameter = esCalismaDurumu != null ?
        new ObjectParameter("EsCalismaDurumu", esCalismaDurumu) :
        new ObjectParameter("EsCalismaDurumu", typeof(string));

    return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<decimal>>("p_PersonelEkleAgiGetir", medeniDurumParameter, cocukSayisiParameter, esCalismaDurumuParameter);
}

If I understand your question well, you want to know why deleting the N s makes it run correctly but with the N s it doesn't run. 如果我很好地理解了您的问题,那么您想知道为什么删除N s可以使其正常运行,但是使用N s不能运行。 The N indicates that the string is a Unicode . N表示字符串是Unicode When you erase them, the procedure accepts it because it accepts non-Unicode strings. 擦除它们时,该过程将接受它,因为它接受非Unicode字符串。 You can see more information here: 您可以在此处查看更多信息:

What is the meaning of the prefix N in T-SQL statements? T-SQL语句中前缀N的含义是什么?

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

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