llblgenProDataSource and related entities

Posts   
 
    
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 13-Jul-2006 20:56:31   

I am trying to use an llblgenprodatasource loaded with an EtitiyColection (self serv) in an ASP.Net GridView. We must allow editing of a coulple of fields and I need to reference a few fields from a related table in design mode. Typically I would use the standard dot notation to reference nested data ie.

SaleDetail.InvRecord.description

How can nested data be referenced in design mode using this control?

Thanks

Glenn

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 14-Jul-2006 05:11:56   

In the designer edit the SaleDetail entity. Select the Fields on Related Fields tab. Now select the InvRecord.Description item from the drop down and click the add button to add this field to your SaleDetail entity. You will now be able to access SaleDetail.InvRecord.Description using SaleDetail.Description.

You will want to be sure to define the InvRecord prefetch path when you are fetching the SaleDetail collection. Otherwise a separate query would be required for each entity in your collection when you accessed the SaleDetail.Description record.

glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 14-Jul-2006 13:25:05   

Terrific! Thanks very much for the solution.

Glenn

glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 14-Jul-2006 17:50:12   

Just curious, what code would I need in a sub-class of my standard saledetail entity or saledetailcollection which would accomplish this in a NON Declaritive way. I only need this "view" of the saledetails for 2 specific presentations and I do not need the inv.description property for all the other (many) instanciations of the saledetail entity class.

Thanks

Glenn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 14-Jul-2006 19:17:57   

You could use a prefetch path to fetch the related entities and in the HTML you could do something like: <%# ((InvRecordEntity)Eval("InvRecord").Description%>

Frans Bouma | Lead developer LLBLGen Pro
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 14-Jul-2006 19:54:23   

Otis wrote:

You could use a prefetch path to fetch the related entities and in the HTML you could do something like: <%# ((InvRecordEntity)Eval("InvRecord").Description%>

Yes I could but I am trying to use an llblgenprodatasource loaded with an EtitiyColection. I am trying to avoid adding fields on relations for my "standard" saledetails, but make some kind of a subclass which has the additional field. I would then reference this class as the datasource for the llblgenprodatasource.

Thanks

Glenn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 14-Jul-2006 20:22:35   

glennpd wrote:

Otis wrote:

You could use a prefetch path to fetch the related entities and in the HTML you could do something like: <%# ((InvRecordEntity)Eval("InvRecord").Description%>

Yes I could but I am trying to use an llblgenprodatasource loaded with an EtitiyColection. I am trying to avoid adding fields on relations for my "standard" saledetails, but make some kind of a subclass which has the additional field. I would then reference this class as the datasource for the llblgenprodatasource.

my example is using a related entity, namely the entity returned by the InvRecord property simple_smile So you just fetch: SaleDetail entities and their related InvRecordEntity entities and at runtime the databinding in the saledetail gridview using the snippet above, will show the description. Of course you have to add a column to the grid which is templated and not bound to a field in the SaleDetail entity. That's teh description column for InvRecord.

I hope I make sense. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 15-Jul-2006 23:28:15   

Otis wrote:

glennpd wrote:

Otis wrote:

You could use a prefetch path to fetch the related entities and in the HTML you could do something like: <%# ((InvRecordEntity)Eval("InvRecord").Description%>

Yes I could but I am trying to use an llblgenprodatasource loaded with an EtitiyColection. I am trying to avoid adding fields on relations for my "standard" saledetails, but make some kind of a subclass which has the additional field. I would then reference this class as the datasource for the llblgenprodatasource.

my example is using a related entity, namely the entity returned by the InvRecord property simple_smile So you just fetch: SaleDetail entities and their related InvRecordEntity entities and at runtime the databinding in the saledetail gridview using the snippet above, will show the description. Of course you have to add a column to the grid which is templated and not bound to a field in the SaleDetail entity. That's teh description column for InvRecord.

I hope I make sense. simple_smile

When I try to create the prefetch path with :

Dim prefetchPath As IPrefetchPath = New PrefetchPath(CInt(EntityType.SaleDetailEntity))

the VS2005 ide says ""EntityType" Type not declared

I don't understand ???

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 16-Jul-2006 00:24:47   

Did you add an Import rootnamespace at the top of your code file?

Frans Bouma | Lead developer LLBLGen Pro
glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 17-Jul-2006 13:12:45   

Otis wrote:

Did you add an Import rootnamespace at the top of your code file?

My face is RED! I had an IMPORT statememnt for AWS which is a class, not AWS_DAL which is the namespace. I am soooo embarassed.

Thanks

Glenn

glennpd
User
Posts: 30
Joined: 09-Feb-2006
# Posted on: 17-Jul-2006 13:55:07   

Is the underlying collection / entity visible from the llblgendatasource?


<%# (SaledetailEntity)eval("inv").description %>

I am trying to place this expression in a format field and saledetailentity is not known.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 17-Jul-2006 14:30:31   

I think you should be typeCasting to the InvRecordEntity not the SaleDetailEntity. Since you are trying to invoke the InvRecordEntity of the SaleDetailEntity.

Code should look like:

<%# ((InvRecordEntity)Eval("InvRecord")).description %>

Assuming the SaleDetailEntity's InvRecordEntity related field is called "InvRecord". Otherwise change it to the appropriate name.