No mapping exists from object type System.Collections.Generic.List when executing stored proc with parameters in EF 4.3

后端 未结 7 1391
旧巷少年郎
旧巷少年郎 2020-12-30 19:30

Lately I\'ve been working on stored procedure and encountered 1 strange problem.

First, I was able to successfully call a stored procedure from the database via:

相关标签:
7条回答
  • 2020-12-30 20:32

    In my case parameter's SQL type and handling null values solved this problem. It was throwing same exception No mapping exists from object type System.RuntimeType to a known managed provider native type. for this also

    var parameter1 = new SqlParameter("parameter1", typeof(string));
    var parameter2 = new SqlParameter("parameter2", typeof(string));
    var parameter3 = new SqlParameter("parameter3", typeof(string));
    
    parameter1.Value = string.IsNullOrEmpty(parameter1Value) ? (object)DBNull.Value : parameter1Value;
    parameter2.Value = string.IsNullOrEmpty(parameter2Value) ? (object)DBNull.Value : parameter2Value;
    parameter3.Value = string.IsNullOrEmpty(parameter3Value) ? (object)DBNull.Value : parameter3Value;
    

    http://karim-medany.blogspot.ae/2014/02/no-mapping-exists-from-object-type.html

    0 讨论(0)
提交回复
热议问题