EntityA.B refers to EntityB

EntityB.Item refers to IItem (persistent interface type)

from a in Session.Query.All<EntityA>()
where a.User == myUser
group a by a.B into g
select new { g.Key.Item.Name, Count = g.Count() };

Throws KeyNotFound exception.

If you remove g.Key.Item.Name from the select list (and replace it with something like g.Key.SomeValueField), it works.

In the meantime, I made a workaround to select g.Key (then access what would be g.Key.Item.Name through code), and added a prefetch for what would be g.Key.Item.Name so that there isn't a second roundtrip to DB.

asked Feb 01 '11 at 17:58

ara's gravatar image

ara
395878791

edited Feb 02 '11 at 08:10

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

We've investigated the case and found a bug. Fixing...

(Feb 02 '11 at 08:12) Dmitri Maximov Dmitri%20Maximov's gravatar image

Also, DO throws a KeyNotFoundException for this:

public class MyEntity : Entity {
  [Field]
  public MyStatus Status { get; set; }  // Enum
}

public class MyEntityViewModel {
  public string Status { get; set; }

  public MyEntityViewModel(MyStatus status) {
    Status = status.ToString();
  }
}

...

var x = from e in Session.Query.All<MyEntity>() select new MyEntitiyViewModel(e.Status)

Seems like it does this because the property in the projected type is of a different type than the field in the entity.

(Feb 02 '11 at 12:27) ara ara's gravatar image

One Answer:

Both issues are resolved in version 4.3.7 and 4.4 Beta 2 as well. Updated binaries will be available soon. Stay tuned.

answered Feb 04 '11 at 04:43

Alexis%20Kochetov's gravatar image

Alexis Kochetov
1414

The updated installers and binaries are published. You need build 7186 or higher.

(Feb 07 '11 at 07:21) Dmitri Maximov Dmitri%20Maximov's gravatar image

Great, thanks, will test it shortly. Any chance we can get the build with the new PostSharp? I'd like to see the affect on compile time!

(Feb 07 '11 at 07:23) ara ara's gravatar image

We are releasing 4.4 final this week and will have a chance to start PostSharp 2.1 investigation right after that.

(Feb 07 '11 at 07:25) Dmitri Maximov Dmitri%20Maximov's gravatar image
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