简体   繁体   English

Linq查询返回异常

[英]Linq query returning exception

So I have this piece of code : 所以我有这段代码:

var imageList = (from stepImages in xrmContext.SdkMessageProcessingStepImageSet
       where stepImages.IsNotNull() && stepImages.SdkMessageProcessingStepId.Id == tempPluginStep.steps.Id
                select new
                {
                     stepImages

                }).ToList();

The problem with it is that it's returning a "Sequence contains no element" exception and I though .ToList would return an empty IEnumerable if there was no elements selected. 它的问题是它返回一个“Sequence contains no element”异常,但是我会。如果没有选择元素,.ToList将返回一个空的IEnumerable。 What seem to be the problem? 什么似乎是问题?

Try replacing this: 尝试替换这个:

select new
{
   stepImages
}

With: 附:

select stepImages

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM