我通过存储过程使用
Dapper进行一些只读数据库调用.我有一个查询将返回1行或没有.
我正在使用这样的Dapper:
@H_301_4@using (var conn = new sqlConnection(ConnectionString)) { conn.Open(); return conn.Query<CaSEOfficer>("API.GetCaSEOfficer",new { Reference = reference },commandType: CommandType.StoredProcedure).FirstOrDefault(); }返回的CaSEOfficer对象如下所示:
@H_301_4@public class CaSEOfficer { public string Title { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public string Telephone { get; set; } }然后通过ASP.NET Web API应用程序将其作为JSON返回.
当存储过程返回结果时,我得到以下内容:
@H_301_4@{ title: "Mr",firstName: "Case",lastName: "Officer",email: "test@example.com",telephone: "01234 567890" }但当它返回什么我得到:
@H_301_4@{ title: null,firstName: null,lastName: null,email: null,telephone: null }