列表获取空值,即使表中有值 [英] list getting the null values even there are values in table

查看:99
本文介绍了列表获取空值,即使表中有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在存储库中有一个方法,当我在wcfservice中调用该方法时,它将列表返回为null但是当我运行查询时它运行良好但是在服务中方法它返回一个空列表...我不知道问题出在哪里..



我的代码是这样的:

方法是:

public List< BUILD_INFO> GetChartInfo(string lineNo,string shiftDateTime,string station)

{

string query = string.Format(" SELECT SUM(QTY_BUILD)AS BUILD_QTY,SUM(QTY_FAIL)AS FAIL_QTY,+

DATEPART(HH,BUILD_HOUR)从BUILD_INFOWITH(NOLOCK)SHIFT_HOURS" +

" WHERE LINE_NO ='{0}'和BUILD_HOUR> ='{1}'和STATION ='{2}'" +

" GROUP BY DATEPART(HH,BUILD_HOUR)ORDER BY SHIFT_HOURS",_ tableName,lineNo,shiftDateTime,电台);



返回MYRepository.Fetch< BUILD_INFO>(查询);

}

i我叫这个服务中的方法如下:



var buildInfo = new BuildInfoRepository();

var build = buildInfo.GetChartInfo(lineNo,datetime,车站);



构建我是ge只提供null ..



提前感谢..



kpr。

Hi,
I have a method inside the repository, when i am calling that method in the wcfservice it returns the list as null but when i am running the query it is running well but in service method it returns a null list... i dont know where the problem is ..

my code is like this:

in repository the method is :
public List<BUILD_INFO> GetChartInfo(string lineNo, string shiftDateTime, string station)
{
string query = string.Format("SELECT SUM(QTY_BUILD) AS BUILD_QTY, SUM(QTY_FAIL) AS FAIL_QTY, "+
"DATEPART(HH,BUILD_HOUR) AS SHIFT_HOURS FROM BUILD_INFOWITH (NOLOCK) "+
"WHERE LINE_NO='{0}' AND BUILD_HOUR >='{1}' AND STATION='{2}' "+
"GROUP BY DATEPART(HH,BUILD_HOUR) ORDER BY SHIFT_HOURS ",_tableName, lineNo, shiftDateTime, station);

return MYRepository.Fetch<BUILD_INFO>(query);
}
i am calling this method in the service as follows:

var buildInfo=new BuildInfoRepository();
var build=buildInfo.GetChartInfo(lineNo,datetime,station);

in build i am getting null only..

thanks in advance..

kpr.

推荐答案

不确定我是否遗漏了任何东西,但你确实声明了4个变量,但我没有看到第一个的占位符。它仅从{1}开始。 {0}在哪里?
Not sure if I am missing anything but you do declare 4 variables but I do not see the place holder for the first. It only starts at {1}. Where is {0}?


这篇关于列表获取空值,即使表中有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆