tzw623583668 2015-05-08 03:10 采纳率: 0%
浏览 1846

报错:未将对象引用设置到对象的实例。下面是代码

public class Temporary
{
//public string Query_NAME { get; set; }
public long Te_TC { get; set; }
public long Te_MC { get; set; }
public long Te_QC { get; set; }
public long Te_WC { get; set; }
public long Te_CC { get; set; }
public long Te_EC { get; set; }
public long Te_PC { get; set; }
}
private DataServiceCollection temporary;

    public DataServiceCollection<Temporary> AllTemporary
    {
        get { return temporary; }
        set
        {
            if (temporary != value)
            {
                temporary = value;
                this.OnPropertyChanged("AllTemporary");
            }
        }
    }

    public object QueryInventoryInfo(string areaId)
    {

        if (string.IsNullOrEmpty(areaId))
        {
            areaId = "";
        }
        string locType = "2";
        for (int i = 0; i < Areas.Count; i++)
        {
            Temporary tem = new Temporary();
            tem.Te_TC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)).LongCount();
            tem.Te_MC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("m")).LongCount();
            tem.Te_QC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("q")).LongCount();
            tem.Te_WC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("w")).LongCount();
            tem.Te_CC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("c")).LongCount();
            tem.Te_EC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("e")).LongCount();
            tem.Te_PC = this.WMSServiceContext.MD_LOCATION.Where(c => c.LOC_TYPE != locType && c.AREA_ID.StartsWith(areaId)
                                                                     && c.STATUS.Contains("p")).LongCount();
            if (tem != null)
            {
                this.AllTemporary.Add(tem);
                                    //此处报错
            }
        }
        return AllTemporary;
    }
  • 写回答

3条回答 默认 最新

  • 逝_去_的_光_阴 2015-05-08 05:03
    关注

    AllTemporary没初始化?

    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法