lkmcelik
lkmcelik

Reputation: 77

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);
}

Upvotes: 0

Views: 76

Answers (1)

TheEsnSiavashi
TheEsnSiavashi

Reputation: 1255

If I understand your question well, you want to know why deleting the Ns makes it run correctly but with the Ns 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?

Upvotes: 1

Related Questions