异常运行LINQ [英] exception running LINQ

查看:68
本文介绍了异常运行LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下Linq序列。 EndDate,StartDate和Department是RMWBRollup表中的列。

I am running the following Linq sequence. EndDate, StartDate and Department are columns in the RMWBRollup table.

IEnumerable< RMWBRollup> resultQuery2;

IEnumerable<RMWBRollup> resultQuery2;

DateTime pivotdate = DateTime.Now.AddDays(1000);           

DateTime pivotdate = DateTime.Now.AddDays(1000);           

APFileEntities context = new APFileEntities() ;

resultQuery2 = context.RMWBRollups.Where(z => z .EndDate> pivotdate&& z.StartDate< pivotdate)。ToList();

resultQuery2=context.RMWBRollups.Where(z=>z.EndDate > pivotdate && z.StartDate < pivotdate).ToList();

start的值为"d"。

查询后

After a query

resultQuery2 = resultQuery2.Where(z => z.Department.ToUpper()。StartsWith(start.ToUpper()));

我跑的时候

int c = resultQuery2.Count();

int c = resultQuery2.Count();

我得到例外

"对象引用未设置为对象的实例。"

"Object reference not set to an instance of an object."

使用调试器我得到

_COMPlusExceptionCode   -532462766   int <查询本身中的

_COMPlusExceptionCode   -532462766   int
in the query itself

类似(相同)的查询适用于其他6列。我再收到一个列的错误。

感谢您尝试提供帮助

Marek

Marek

推荐答案

也许某些
部门值是否为空?可以调整查询以忽略它们。

Maybe some of Department values are null? The query can be adjusted to ignore them.


这篇关于异常运行LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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