34

When I attempt to expand a navigation property via lambda like so:

query = query.Expand(x => x.Dealers);

My query fails with

This is a failure message

Inner Exception

Inner Exception

Inner Exception Message:

The expression 'x => x.Dealers' is not a valid expression for navigation path. The only supported operations inside the lambda expression body are MemberAccess and TypeAs. The expression must contain at least one MemberAccess and it cannot end with TypeAs.

Yet when I attempt to expand via a string parameter:

query = query.Expand("Dealers");

Everything appears to work correctly.

My "Region" Breeze Client Entity:

public class Region : BaseEntity
{
    public Region();

    public NavigationSet<Dealership> Dealers { get; set; }
    public string Name { get; set; }
    public Region Parent { get; set; }
    public int? ParentId { get; set; }
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    [Key]
    public int RegionId { get; set; }
    public string ShortName { get; set; }
    public RegionType Type { get; set; }
}

My Dealership navigation entity:

public class Dealership : BaseEntity
{
    public Dealership();

    public DateTime ActiveFrom { get; set; }
    public DateTime? ActiveTo { get; set; }
    public Brand Brand { get; set; }
    [ForeignKey("Brand")]
    public int BrandId { get; set; }
    public string DealerCode { get; set; }
    public DealerGroup DealerGroup { get; set; }
    [ForeignKey("DealerGroup")]
    public int? DealerGroupId { get; set; }
    public virtual NavigationSet<DealerIR> DealerIRs { get; set; }
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    [Key]
    public int DealershipId { get; set; }
    public bool IsActive { get; set; }
    public string Line1 { get; set; }
    public string Line2 { get; set; }
    public string Line3 { get; set; }
    public string Line4 { get; set; }
    public string Line5 { get; set; }
    public string Name { get; set; }
    public string PostCode { get; set; }
    public Region Region { get; set; }
    [ForeignKey("Region")]
    public int RegionId { get; set; }
}

My latest attempt was to make the foreign key relationship explicit via the "ForeignKey" data annotation, but the resulting error is still the same.

I'm using breeze sharp v0.6.0.3.

UPDATE 1: It's not the exact same query as above, but same result. Just a screenshot from the Breeze.Sharp source code I've been stepping through. Larger image here

enter image description here

7
  • What does the original query look like? i.e. 'query' in your example Commented May 28, 2015 at 4:21
  • 1
    Hi Jay, original query is: EntityQuery<Region> query = new EntityQuery<Region>(); On a slightly different note, I solved another expand issue I was having due to the fact that the I didn't have my "many" navigation properties set to "NavigationSet" (they were simply just List<>) on my client Breeze entities. I'm in the process of correcting that throughout my object graph. Could it be related? Commented May 28, 2015 at 7:58
  • I've changed all the navigation properties to NavigationSet<>... still no dice. Will update OP with the Breeze.Sharp code piece where it's failing... perhaps it will help.. Commented May 28, 2015 at 8:11
  • I'll try to repro this, but I probably won't get to it until next week... Commented May 28, 2015 at 8:38
  • 1
    It is still under active dev, but lately we've been focusing on our server story. i.e. new Node and Java servers in addition to our .NET one. but we are beginning to get more interest in Breeze# so I'll probably be getting back to it in a few weeks. At that time, I'll try to author up a doc that describes the tests that need to pass for us to take a pull request. After that I'd love any help :) Commented May 28, 2015 at 19:21

2 Answers 2

1

Try like followings

query = query.ToList().Expand(val => val.Dealers);
Sign up to request clarification or add additional context in comments.

2 Comments

I don't think the Expand extension method is even available on Linq2Objects?
Please add explanation to your answer.
1
query = query.Include(val => val.Dealers);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.