Projection Fields

Posts   
 
    
bfive
User
Posts: 2
Joined: 08-May-2012
# Posted on: 08-May-2012 16:59:08   

Please help me about how I can create a projection with fields from one entity and a field or more from a parent related entity (m:1) (e.g. Order.Id, Order.Date and Order.Customer.Name). Many Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 08-May-2012 21:54:13   

Are you speaking about projection as linq?

bfive
User
Posts: 2
Joined: 08-May-2012
# Posted on: 08-May-2012 22:54:56   

Walaa wrote:

Are you speaking about projection as linq?

No, I don't; I use the SelfServicing pattern/model and I want to create a View on an Entity to bind to a datagrid, but I need to display several fields from related parent entity. I use a datagrid which does not recognize the parent entity property as a field, then I think it is necessary to create a view; but, is there a mode to bind a grid column to parent field in a m:1 entity relation? Thanks Regards

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-May-2012 05:30:15   

There are more than one approach. If you want data in a read only fashion, you can use a DynamicList

You can have this built at design time, using a TypedList

If you want data for Read/write, then you may fetch the related entity using a prefetchPath then you may add propertis to the main entity class (preferably in a partial class), which return the value of the parent entity properties, and use these in databinding.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 09-May-2012 10:06:14   

I still think you do mean a projection like with linq.

from o in metaData.Order select new { o.OrderId, o.OrderDate, CustomerName = o.Customer.CompanyName };

Frans Bouma | Lead developer LLBLGen Pro