views:

61

answers:

1

Hey,

This works:

    projections.Add(Projections.Property(Member<MailOrder>.From(x => x.AssigneeCode).QualifiedPath), Member<MailOrderItem>.From(x => x.AssigneeCode).Path);
    projections.Add(Projections.Property(Member<MailOrder>.From(x => x.AssigneeName).QualifiedPath), Member<MailOrderItem>.From(x => x.AssigneeName).Path);
    projections.Add(Projections.Property(Member<MailOrder>.From(x => x.AssigneeType).QualifiedPath), Member<MailOrderItem>.From(x => x.AssigneeType).Path);            

This does not off course

projections.Add(Projections.Property(Member<IMailOrderAssignee>.From(x => x.AssigneeCode).QualifiedPath), Member<MailOrderItem>.From(x => x.Code).Path);
projections.Add(Projections.Property(Member<IMailOrderAssignee>.From(x => x.AssigneeName).QualifiedPath), Member<MailOrderItem>.From(x => x.GetName()).Path);
projections.Add(Projections.Property(Member<IMailOrderAssignee>.From(x => x.AssigneeType).QualifiedPath), Member<MailOrderItem>.From(x => x.GetType()).Path);            

This does not work because of two things:

  1. there is no persister for theinterface
  2. Methods are used in Property way.

I've searched a lot in the world of Nhiberante, but it seems to me that this is quite difficult.

The IMailOrderAssignee is an interface for two rootentity's (let's call them RootX and RootY). In the context of my MailOrders, it isn't important what root it is, as long as I have a reference to it + The Name and it's code and emailaddresses.

The IMailOrderAssignee is mapped with the any - tag in the mapping file. (that works brilliant, but I could do it with an discriminator also).

My question:

  1. Is it possible to use the result of a method in a projection query so the result is in the DTO?

  2. Is it possible to uses contracts in projection querys (I guess not...)

+1  A: 

Why not do the projection in memory?

Example:

var criteria = someCriteriaThatReturnsPersistentEntities;
var items = criteria.List<IMailOrderAssignee>();
var projected = items.Select(i => new
                                  {
                                      Prop1 = i.SomeMethod(),
                                      Etc
                                  });
Diego Mijelshon
Yes, This can help.But I also got another problem using the <any/> tag. It lays down a FK constraints to only one of the tables.So, I backed down, wait a little, and saw that I was seeing this <<wrongly>>. It was not the data that they shared, but behavior. I only shared the ID... and that's not right... The MailOrders shared everything, except there reference, so I used the Inheritence mapping.Thanks for your answer though, I learned something from it => It is not possible in the projection query itself, but afterwards i can do my stuff :D
kriebb