System.InvalidOperationException occurred
Message=Sequence contains no elements.
   at     Xtensive.Orm.Linq.Materialization.MaterializationHelper.ThrowEmptySequenceException() in     d:\Home\\Xtensive.Orm\Xtensive.Orm\Orm\Linq\Materialization\MaterializationHelper.cs:line 100

It occurs when executing select with anonymous object with many parameters

var header = Query.All<BondPayment.TpSumToPayment>()
.Select(a => new
    DepositorName = a.Person.ShortName,
    DepoAccount = a.DepoAccount.Number,
    FinToolName = a.FinTool.Name,
    FinToolType = a.FinTool.FinToolType.Name,
    Number = (a.FinTool as Bond).ReleaseNumber,
    RegNumber = (a.FinTool as Bond).RegistrationReleaseNumber,
    RegNumberDate = (a.FinTool as Bond).RegistraionReleaseNumberDate,
    Period = a.Owner.CouponOnBonds.Where(q => q.FinTool == a.FinTool).First().CouponPaymentPlan.NumberOfCouponPeriod,
    SecDate = a.Owner.SectionDate,
    SignPost = a.Owner.Signatory.Post.Name,
    SignName = a.Owner.Signatory.Name,
    FinToolNominal = (a.FinTool as Bond).Nominal,
    CouponIncome = a.Owner.CouponOnBonds.Where(q => q.FinTool == a.FinTool).First().AccumulatedCouponIncome,
    Maturity = a.Owner.CouponOnBonds.Where(q => q.FinTool == a.FinTool).First().MaturityValue,
    FinToolsQty = a.FinToolQty,
    Summ = a.Sum

asked Apr 12 '11 at 11:21

pil0t's gravatar image


edited Apr 13 '11 at 09:56

Dmitri%20Maximov's gravatar image

Dmitri Maximov

Hello pil0t,

Could you provide a sample or a test case for this, so we could reproduce the problem? Also, are there any chance that the real problem is not in the number of fields but just in one of them? Try removing the fields by one, starting from primitive ones, may be this approach will help distinguishing the erroneous field?

(Apr 13 '11 at 10:00) Dmitri Maximov Dmitri%20Maximov's gravatar image

Example is quite difficult, but it is defenetly poblem in number or combinations of properties. Removing any half of properties fixes problem

(Apr 13 '11 at 10:15) pil0t pil0t's gravatar image

One Answer:


First of all, try changing .First() to .FirstOrDefault() member call. If this doesn't help, then the only way to sort out the problem is to find out the erroneous field combination by removing expressions one by one.

Hope that helps.

answered Apr 13 '11 at 10:26

Dmitri%20Maximov's gravatar image

Dmitri Maximov

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA