我尝试使用模型来获取执行存储过程的容器,但是它告诉我SP.GR0007R上的SP是一个变量,它是模型的变量,但它像类型一样使用,但是如果我使用Cont.ReportManager.GR0007R,没有发现错误,也没有结果。
这是我的代码:
using (var db = new SqlConnection(connStr))
{
var param = new DynamicParameters();
switch (filter.RPTCode)
{
case "GR0007R":
param.Add("@Name", !string.IsNullOrEmpty(filter.NAME) ? filter.NAME : string.Empty);
var sp7r = await db.QueryAsync<SP.GR0007R>(filter.RPTQuery, param, commandType: CommandType.StoredProcedure);
break;
}
res = true;
}这是我声明SP的地方
public async Task<bool> GetReportData(Models.ReportManager.EswisReportModel SP, GetListParameterReportList filter)这是我的模型
public class EswisReportModel
{
public Cont.ReportManager.GR0001R GR0001R { get; set; }
public Cont.ReportManager.GR0002R GR0002R { get; set; }
public Cont.ReportManager.GR0007R GR0007R { get; set; }
public Cont.ReportManager.GR0008R GR0008R { get; set; }
public Cont.ReportManager.GR0009R GR0009R { get; set; }
}那么我是必须转换它,还是有其他方式调用它呢?谢谢
发布于 2018-10-08 15:38:13
看起来你正在尝试放入一个实例和属性名,并希望泛型处理会如此智能,以便知道你指的是该属性的后备类型。根据C#规范,您需要使用类型名,而不是对它的引用,也不是通过变量名对它的某种推断使用。
这就是为什么应该使用实际的类型名Cont.ReportManager.GR0007R的原因
var sp7r = await db.QueryAsync<Cont.ReportManager.GR0007R>(...);https://stackoverflow.com/questions/52697415
复制相似问题