Strange Exception with conditional operator, example query:

                var tp = from q in Query.All<TpPriceCalc>()
                          select new { q.Account, Check = !q.Check, FinToolKind = q.Check ? null : q.Owner };

                var masterCredit = Query.All<PacioliPosting>();

                var result = from r in masterCredit
                                 .LeftJoin(tp, a => a.CreditAccount, a => a.Account, (a, pm) => new { pp = a, pm })
                             let q = r.pp
                             select new 
                             {
                                 Id = q.Id,
                                 MasterFinToolKind = r.pm == null 
                                     ? (FinToolKind)null 
                                     : (!r.pm.Check ? r.pm.FinToolKind : q.FinCredit.FinToolKind)
                             };

                var rr = result.ToArray();

and model

public abstract class EntityBase : Entity
{
    protected EntityBase(Guid id) : base(id) { }
    [Field, Key] public Guid Id { get; private set; }
}

[HierarchyRoot]
public class TpPriceCalc : EntityBase
{
    public TpPriceCalc(Guid id) : base(id) { }
    [Field] public bool Check { get; set; }
    [Field] public Account Account { get; set; }
    [Field] public FinToolKind Owner { get; set; }
}

[HierarchyRoot]
public class FinToolKind : EntityBase
{
    public FinToolKind(Guid id) : base(id) {}
}

[HierarchyRoot]
public class PacioliPosting : EntityBase
{
    public PacioliPosting(Guid id) : base(id) { }
    [Field] public Account CreditAccount { get; set; }
    [Field] public FinToolBase FinCredit { get; set; }
}

[HierarchyRoot]
public class FinToolBase : EntityBase
{
    public FinToolBase(Guid id) : base(id) { }
    [Field] public FinToolKind FinToolKind { get; set; }
}

[HierarchyRoot]
public class Account : EntityBase
{
    public Account(Guid id) : base(id) { }
}

asked May 27 '15 at 08:05

pil0t's gravatar image

pil0t
207535763


One Answer:

Hello pil0t.

It happens because of comparison of anonymous type with null value. DataObjects.Net can't detect correct type of null. I fixed this behavior in development branch. Next version will contain this bug-fix.

answered May 29 '15 at 06:07

Alexey%20Kulakov's gravatar image

Alexey Kulakov
48215

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