Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Queryspec Projection Capability
 

Pages: 1
LLBLGen Pro Runtime Framework
Queryspec Projection Capability
Page:1/1 

  Print all messages in this thread  
Poster Message
arschr
User



Location:
Atlanta, Georgia; USA
Joined on:
14-Dec-2003 16:57:29
Posted:
887 posts
# Posted on: 20-Jun-2014 18:22:06.  
I'm trying this with LlblGen v4.2 beta but don't think it is specific to that version.

I have an entity File and a related entity FileActivity (1->n).
I am trying to use queryspec to retrieve a set of File entities and the related FileActivity entities.

I would like to project the File entities into a List<FileModel> where FileModel is a poco and FileModel has a property which is a List<FileActivityModel> which would hold the related projected FileActivity entities.

I think I see something close to this in the documentation here
Quote:

var qf = new QueryFactory();
var q = qf.Customer
     .Where(CustomerFields.Country == "Germany")
     .Select(() => new
     {
        CustomerId = CustomerFields.CustomerId.ToValue<string>(),
        Orders = qf.Order
                    .CorrelatedOver(OrderEntity.Relations.CustomerEntityUsingCustomerId)
             .Select(() => new
             {
                OrderId = OrderFields.OrderId.ToValue<int>(),
                OrderDate = OrderFields.OrderDate.ToValue<DateTime?>()
             })
             .ToResultset()
     });


But I don't see how to make the Orders collection in the help a List<OrderModels>

Can it be done? If so a sample would help.

Then a related question would be how to do the same projection when the relateed entities are retrieved using .WithPath and .WithSubPath?
- Al  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8137 posts
# Posted on: 21-Jun-2014 03:53:10.  
You can use a basic projection right in the .Select construct:
Code:
return qf.Create("oq")
            .Select(() => new OrderData
            {
                CustomerId = OrderFields.CustomerId.ToValue<string>(),
                OrderId = OrderFields.OrderId.ToValue<int>(),
                EmployeeIdAsFloat = OrderFields.EmployeeId.ToValue<int>()
            });


You also could use .WithProjector, which is more powerful, as you can write your conversion code. See Specifying the type of a DynamicQuery resultset for explanation and examples.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.