Help in projection

Posts   
 
    
prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 04-Sep-2008 11:10:38   

Hi,

I need to project data into the following DTO based on projection.

public class TerritoryKPIInfo
{
    private int id;
    private int noOfPersons;

    public int Id
    {
        get { return id; }
        set { id = value; }
    }

    public int NoOfPersons
    {
        get { return noOfPersons; }
        set { noOfPersons  = value; }
    }
}

The query to project data into dto is

SELECT X.potentialId, Count(X.personId) as NoOfPersons FROM ( SELECT PP.personId, (SELECT id FROM Persons.Potential WHERE weight = Max(PO.weight)) potentialId FROM Territory.Territory T,Territory.TerritoryDetail TD, Persons.PersonProduct PP,Territory.ProductPortfolioDetail PPD, Persons.Potential PO, Persons.Usage US WHERE T.id = 50 AND TD.territoryId = T.id AND 92 BETWEEN TD.startPeriod AND ISNULL(TD.endPeriod, 9999999) AND PP.personId = TD.personId AND PP.productId = PPD.productId AND PPD.productPortfolioId = T.productPortfolioId AND PPD.principal = 1 AND PO.id = PP.potentialId AND US.id = PP.usageId Group By PP.personId) X Group By X.potentialId

Please help me to define the resultset fields for the above query.

Regards

Prabhu

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Sep-2008 12:13:33   

Which version of LLBLGen Pro are you using?

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 04-Sep-2008 12:19:14   

I am using LLBLGen 2.5 Version.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Sep-2008 12:40:52   

V2.6 has Derived table support (specify a complete query as a FROM clause or as a side of a relation) Also it supports linq.

And since you are using v2.5, I'd say you'll have to create a SP for this query and then fetch it into a IDataReader that can be projected into a cutom class. Please check this link: Generated code - Fetching DataReaders and projections, Adapter