Using CustomProperties in Dynamic List?

Posts   
 
    
prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 11-May-2007 05:53:43   

Hi,

I am creating a dynamic list (read only scenario) to project data into custom DTO object .

I am having a table called location which contains reference to a subbrick table. Subbrick contains reference to GeographyResource table.(All the master data related info will be stored in Resource tables)

Location --------> SubBrick ----------> GeographyResource (SubBrickId) (DescriptionId) (Id)

In order to get the Subrickname for a given location what i had done is written a partial class for locationentity and write custom properties to retrieve the same.

For the present problem i had written a dynamic list. Need to define fields such as LocationId,LocationName, SubbrickName etc. The first two fields had been taken from filed creation class for location entity. I need to define subbrickname field in Dynamic list. Currently it is defined as an custom property in locationentity.

And also i can't take directly from Subbrick table because in contains only the descriptionid for that subbrick. Need to take from GeographyResource table.

Please let me know how can i define the same by use of expressions.

Regards

Prabhu

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-May-2007 17:28:17   

Would you please post the code you used to create the DynamicList?

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 14-May-2007 03:33:19   

I need to use custom properties in field expressions instead of computing it from columns. Is it possible to the same.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-May-2007 08:57:26   

Would you please post the code you used to create the DynamicList?

I need to use custom properties in field expressions instead of computing it from columns. Is it possible to the same.

Have you checked the "Using the generated code -> Field expressions and aggregates" section in the manual?

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 14-May-2007 10:34:57   

Please refer my original post; I have 3 tables with the following relation.

Location --------> SubBrick ----------> GeographyResource (SubBrickId) (DescriptionId) (Id)

I have defined the fields definition like the below:

ResultsetFields fields = new ResultsetFields(4);

fields.DefineField(LocationFields.Id, 0);

fields.DefineField(ContactInfoFields.Address1, 1);

fields.DefineField(LocationFields.Name, 2);

fields.DefineField(SubBrickNameCustomProperty,3)

Need to know how to get the above customproperty to be used in the defineField method. .I had tried to use Expressions. But i am not able to define the field based on the fields.That subbrickname had been defined as a custom property in location or subbrick entity partial class.

In the above code, LocationId and LocationName can be taken directly from the class LocationFields.

In order to get the Subrickname for a given location, I have to include the SubBrickName in the fields list above. But with the current scenario, I can not refer the SubBrickName of the location directly from the LocationEntity class.

Please also note that, why I have defined the Partial class is, i can't take SubBrickName directly from Subbrick table because in contains only the descriptionId for that subbrick. So based on the descriptionId, I need to take from GeographyResource table.

So, please let me know how to include the Custom Property defined for SubBrickName in the Fields definition, to get the SubBrickName for a given Location or any other solution for the above scenario.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-May-2007 09:07:29   

It's not possible to use an entity's custom property in a dynamicList.

DynamicList uses the generated entitynameFields classes for resultset fields definition. Also you can define a field using an expression.

If you can come up with a SQL query that covers your need, we may be able to help you create the LLBLGen counterpart.

Something like: SELECT Location.ID , ContactInfo.Address1 , Location.Name , (SELECT ..... FROM ....WHERE) as CustomField -- or any kind of expression FROM ... WHERE ...

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 15-May-2007 11:39:04   

Hi,

Walaa thanks for the info...

Please find a sample query below to find the locationname,subbrickname,locationid, subbrickid for a given networkid. Subbrick is a master table in our domain model that contains only the descriptionid. The respective name of subbrick is stored in geographyresource table. In geography resource table the description of master tables details will be stored as an xml string. Master data will be stored in an individual xml element based on the culture info attribute.

select t.locationid, l.name as LocationName, s.id as SubBrickId, gr.id,gr.value

from

Territory.Territory t, locations.location l, geography.subbrick s, geography.brick b, geography.region r, geography.country c, geography.geographyresource gr

where

t.networkid=2 and t.locationid=l.id and l.subbrickid = s.id and s.id=399 and s.brickid = b.id and b.regionid = r.id and r.countryid = c.id and s.descriptionid = gr.id order by t.locationid

The result of the above sample query is attached as an document.

Please let me know how to proceed on this issue.

Regards

Prabhu

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 15-May-2007 11:41:58   

One more thing, in order to retrieve the name of subbrick name we are having a multilingual class to get the name based on the descriptionid's.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 15-May-2007 15:14:16   

Hello,

select t.locationid, l.name as LocationName, s.id as SubBrickId, gr.id,gr.value from Territory.Territory t, locations.location l, geography.subbrick s, geography.brick b, geography.region r, geography.country c, geography.geographyresource gr where t.networkid=2 and t.locationid=l.id and l.subbrickid = s.id and s.id=399 and s.brickid = b.id and b.regionid = r.id and r.countryid = c.id and s.descriptionid = gr.id order by t.locationid

You can defined this request without using a custom property(there is no field that doesn't come from one of your database for the sample you gave, no?) :


ResultsetFields fields = new ResultsetFields(5);
fields.DefineField(LocationFields.Id, 0);
fields.DefineField(LocationFields.Name, 1);
fields.DefineField(SubBrickFields.Id,2);
fields.DefineField(GeographyResourceFields.Id,3);
fields.DefineField(GeographyResourceFields.value,4);

IRelationPredicateBucket rpb=new RelationPredicateBucket()
//here you will defined all your relation and all your predicate
rpb.PredicateExpression.Add(subbrick Fields.Id == "399");
...

DataTable dt=new DataTable();
adapter.fetchTypedList(fields,dt,rpb);