简体   繁体   中英

Entity Framework procedure is not working

When I run this code and watch in SQL Server Profiler, there is no return value

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. 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. The N indicates that the string is a Unicode . When you erase them, the procedure accepts it because it accepts non-Unicode strings. You can see more information here:

What is the meaning of the prefix N in T-SQL statements?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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