Senick
Senick

Reputation: 101

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. What seem to be the problem?

Upvotes: 0

Views: 65

Answers (1)

qJake
qJake

Reputation: 17119

Try replacing this:

select new
{
   stepImages
}

With:

select stepImages

Upvotes: 2

Related Questions