我正在使用Dapper和ASP.NET Core执行存储过程,并返回将在集合中包含一些负值的数据集。我遇到的是,当我执行该过程并填充模型时,所有负数都将转换为0,这不是我想要的(应用程序的目的是允许用户发现负值并更正它们)。出于好奇,我去创建了一个webforms应用程序,以确保它对我的存储过程没有什么奇怪的事情。我能够执行该过程,并看到一切都按预期返回到了Webforms应用程序中的gridview。
我在做什么错?我在模型中定义的东西会告诉它将负值转换为0吗?模型如下图所示:
public class ScadaErrorModel
{
[Display(Name = "Scada Error ID")]
public int ID { get; set; }
//[Display(Name = "Location Description")]
//public string Description { get; set; }
[Display(Name = "Scada Link")]
public string Scada_link { get; set; }
[Display(Name = "Area")]
public string Bwp_Area { get; set; }
[Display(Name = "Asset Number")]
public string Assetnum { get; set; }
[Display(Name = "Asset Description")]
public string Asset_Description { get; set; }
[Display(Name = "Reading Date")]
public DateTime Reading_date { get; set; }
[Display(Name = "Region")]
public string Bwp_region { get; set; }
[Display(Name = "Error Type")]
public string Error_type { get; set; }
[Display(Name = "Comments")]
[DataType(DataType.MultilineText)]
public string Comments { get; set; }
[Display(Name = "Operating Hours")]
public float Operating_hrs { get; set; }
[Display(Name = "Downtime Hours")]
public float Ttl_downtime_hrs { get; set; }
[Display(Name = "Compressor Cylinder Oil Usage (gal)")]
public float Oil_to_comp_cyl { get; set; }
[Display(Name = "Crankcase Oil Usage (gal)")]
public float Oil_to_cc_hand { get; set; }
[Display(Name = "Crankcase Auto Oil Usage (gal)")]
public float Oil_new_cc_ren { get; set; }
[Display(Name = "Power Cylinder Oil Usage (gal)")]
public float Oil_to_pwr_cyl { get; set; }
[Display(Name = "Electricity Usage (kWh)")]
public int Electricity_used { get; set; }
[Display(Name = "Fuel Consumed (mcf)")]
public float Fuel_consumed { get; set; }
[Display(Name = "Horsepower Hours")]
public int hrspwr_hrs { get; set; }
[Display(Name = "RPM - Average Engine Speed")]
public int avg_unit_rpm { get; set; }
[Display(Name = "Start Attempts")]
public int Engine_starts_attempts { get; set; }
[Display(Name = "Start Successes")]
public int Engine_starts_success { get; set; }
[Display(Name = "Start Failed")]
public int Engine_starts_failed { get; set; }
[Display(Name = "Startup Duration (min)")]
public float Startup_duration { get; set; }
[Display(Name = "Throughput/Capacity (mmscf)")]
public float Thruput_mmcf { get; set; }
}
答案 0 :(得分:0)
由于@nurdyguy的建议,我得以弄清楚发生了什么。我仔细研究了模型,然后研究了数据库。自从我为模型编写类以来,数据库已经发生了几处更改。它们中的大多数是次要的,但是有几项是对我正在访问的表中列的基础数据类型的更改。一旦修复了模型中的差异,一切就开始起作用。再次感谢大家的帮助。